Class: Paru::PandocFilter::Citation
- Inherits:
-
Object
- Object
- Paru::PandocFilter::Citation
- Defined in:
- lib/paru/filter/citation.rb
Overview
A Citation consists of an id, a prefix, a suffix, a mode, a note number, and integer hash. All of which are optional.
Instance Attribute Summary collapse
- #hash ⇒ Integer
- #id ⇒ String
- #mode ⇒ String
- #note_num ⇒ Integer
- #prefix ⇒ Array<Inline>
- #suffix ⇒ Array<Inline>
Instance Method Summary collapse
-
#initialize(spec) ⇒ Citation
constructor
Create a new Citation node base on an AST specification.
-
#to_ast ⇒ Object
Convert this Citation to an AST representation.
Constructor Details
#initialize(spec) ⇒ Citation
Create a new Citation node base on an AST specification
51 52 53 54 55 56 57 58 |
# File 'lib/paru/filter/citation.rb', line 51 def initialize(spec) @id = spec["citationId"] if spec.has_key? "citationId" @prefix = Inline.new spec["citationPrefix"] if spec.has_key? "citationPrefix" @suffix = Inline.new spec["citationSuffix"] if spec.has_key? "citationSuffix" @mode = spec["citationMode"] if spec.has_key? "citationMode" @note_num = spec["citationNoteNum"] if spec.has_key? "citationNoteNum" @hash = spec["citationHash"] if spec.has_key? "citationHash" end |
Instance Attribute Details
#hash ⇒ Integer
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/paru/filter/citation.rb', line 45 class Citation attr_accessor :id, :prefix, :suffix, :mode, :note_num, :hash # Create a new Citation node base on an AST specification # # @param spec [Hash] the specification of this citation def initialize(spec) @id = spec["citationId"] if spec.has_key? "citationId" @prefix = Inline.new spec["citationPrefix"] if spec.has_key? "citationPrefix" @suffix = Inline.new spec["citationSuffix"] if spec.has_key? "citationSuffix" @mode = spec["citationMode"] if spec.has_key? "citationMode" @note_num = spec["citationNoteNum"] if spec.has_key? "citationNoteNum" @hash = spec["citationHash"] if spec.has_key? "citationHash" end # Convert this Citation to an AST representation def to_ast() citation = Hash.new citation["citationId"] = @id if not @id.nil? citation["citationPrefix"] = @prefix.ast_contents if not @prefix.nil? citation["citationSuffix"] = @suffix.ast_contents if not @suffix.nil? citation["citationMode"] = @mode if not @mode.nil? citation["citationNoteNum"] = @note_num if not @note_num.nil? citation["citationHash"] = @hash if not @hash.nil? citation end end |
#id ⇒ String
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/paru/filter/citation.rb', line 45 class Citation attr_accessor :id, :prefix, :suffix, :mode, :note_num, :hash # Create a new Citation node base on an AST specification # # @param spec [Hash] the specification of this citation def initialize(spec) @id = spec["citationId"] if spec.has_key? "citationId" @prefix = Inline.new spec["citationPrefix"] if spec.has_key? "citationPrefix" @suffix = Inline.new spec["citationSuffix"] if spec.has_key? "citationSuffix" @mode = spec["citationMode"] if spec.has_key? "citationMode" @note_num = spec["citationNoteNum"] if spec.has_key? "citationNoteNum" @hash = spec["citationHash"] if spec.has_key? "citationHash" end # Convert this Citation to an AST representation def to_ast() citation = Hash.new citation["citationId"] = @id if not @id.nil? citation["citationPrefix"] = @prefix.ast_contents if not @prefix.nil? citation["citationSuffix"] = @suffix.ast_contents if not @suffix.nil? citation["citationMode"] = @mode if not @mode.nil? citation["citationNoteNum"] = @note_num if not @note_num.nil? citation["citationHash"] = @hash if not @hash.nil? citation end end |
#mode ⇒ String
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/paru/filter/citation.rb', line 45 class Citation attr_accessor :id, :prefix, :suffix, :mode, :note_num, :hash # Create a new Citation node base on an AST specification # # @param spec [Hash] the specification of this citation def initialize(spec) @id = spec["citationId"] if spec.has_key? "citationId" @prefix = Inline.new spec["citationPrefix"] if spec.has_key? "citationPrefix" @suffix = Inline.new spec["citationSuffix"] if spec.has_key? "citationSuffix" @mode = spec["citationMode"] if spec.has_key? "citationMode" @note_num = spec["citationNoteNum"] if spec.has_key? "citationNoteNum" @hash = spec["citationHash"] if spec.has_key? "citationHash" end # Convert this Citation to an AST representation def to_ast() citation = Hash.new citation["citationId"] = @id if not @id.nil? citation["citationPrefix"] = @prefix.ast_contents if not @prefix.nil? citation["citationSuffix"] = @suffix.ast_contents if not @suffix.nil? citation["citationMode"] = @mode if not @mode.nil? citation["citationNoteNum"] = @note_num if not @note_num.nil? citation["citationHash"] = @hash if not @hash.nil? citation end end |
#note_num ⇒ Integer
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/paru/filter/citation.rb', line 45 class Citation attr_accessor :id, :prefix, :suffix, :mode, :note_num, :hash # Create a new Citation node base on an AST specification # # @param spec [Hash] the specification of this citation def initialize(spec) @id = spec["citationId"] if spec.has_key? "citationId" @prefix = Inline.new spec["citationPrefix"] if spec.has_key? "citationPrefix" @suffix = Inline.new spec["citationSuffix"] if spec.has_key? "citationSuffix" @mode = spec["citationMode"] if spec.has_key? "citationMode" @note_num = spec["citationNoteNum"] if spec.has_key? "citationNoteNum" @hash = spec["citationHash"] if spec.has_key? "citationHash" end # Convert this Citation to an AST representation def to_ast() citation = Hash.new citation["citationId"] = @id if not @id.nil? citation["citationPrefix"] = @prefix.ast_contents if not @prefix.nil? citation["citationSuffix"] = @suffix.ast_contents if not @suffix.nil? citation["citationMode"] = @mode if not @mode.nil? citation["citationNoteNum"] = @note_num if not @note_num.nil? citation["citationHash"] = @hash if not @hash.nil? citation end end |
#prefix ⇒ Array<Inline>
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/paru/filter/citation.rb', line 45 class Citation attr_accessor :id, :prefix, :suffix, :mode, :note_num, :hash # Create a new Citation node base on an AST specification # # @param spec [Hash] the specification of this citation def initialize(spec) @id = spec["citationId"] if spec.has_key? "citationId" @prefix = Inline.new spec["citationPrefix"] if spec.has_key? "citationPrefix" @suffix = Inline.new spec["citationSuffix"] if spec.has_key? "citationSuffix" @mode = spec["citationMode"] if spec.has_key? "citationMode" @note_num = spec["citationNoteNum"] if spec.has_key? "citationNoteNum" @hash = spec["citationHash"] if spec.has_key? "citationHash" end # Convert this Citation to an AST representation def to_ast() citation = Hash.new citation["citationId"] = @id if not @id.nil? citation["citationPrefix"] = @prefix.ast_contents if not @prefix.nil? citation["citationSuffix"] = @suffix.ast_contents if not @suffix.nil? citation["citationMode"] = @mode if not @mode.nil? citation["citationNoteNum"] = @note_num if not @note_num.nil? citation["citationHash"] = @hash if not @hash.nil? citation end end |
#suffix ⇒ Array<Inline>
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/paru/filter/citation.rb', line 45 class Citation attr_accessor :id, :prefix, :suffix, :mode, :note_num, :hash # Create a new Citation node base on an AST specification # # @param spec [Hash] the specification of this citation def initialize(spec) @id = spec["citationId"] if spec.has_key? "citationId" @prefix = Inline.new spec["citationPrefix"] if spec.has_key? "citationPrefix" @suffix = Inline.new spec["citationSuffix"] if spec.has_key? "citationSuffix" @mode = spec["citationMode"] if spec.has_key? "citationMode" @note_num = spec["citationNoteNum"] if spec.has_key? "citationNoteNum" @hash = spec["citationHash"] if spec.has_key? "citationHash" end # Convert this Citation to an AST representation def to_ast() citation = Hash.new citation["citationId"] = @id if not @id.nil? citation["citationPrefix"] = @prefix.ast_contents if not @prefix.nil? citation["citationSuffix"] = @suffix.ast_contents if not @suffix.nil? citation["citationMode"] = @mode if not @mode.nil? citation["citationNoteNum"] = @note_num if not @note_num.nil? citation["citationHash"] = @hash if not @hash.nil? citation end end |
Instance Method Details
#to_ast ⇒ Object
Convert this Citation to an AST representation
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/paru/filter/citation.rb', line 61 def to_ast() citation = Hash.new citation["citationId"] = @id if not @id.nil? citation["citationPrefix"] = @prefix.ast_contents if not @prefix.nil? citation["citationSuffix"] = @suffix.ast_contents if not @suffix.nil? citation["citationMode"] = @mode if not @mode.nil? citation["citationNoteNum"] = @note_num if not @note_num.nil? citation["citationHash"] = @hash if not @hash.nil? citation end |