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
53 54 55 56 57 58 59 60 |
# File 'lib/paru/filter/citation.rb', line 53 def initialize(spec) @id = spec['citationId'] if spec.key? 'citationId' @prefix = Inline.new spec['citationPrefix'] if spec.key? 'citationPrefix' @suffix = Inline.new spec['citationSuffix'] if spec.key? 'citationSuffix' @mode = spec['citationMode'] if spec.key? 'citationMode' @note_num = spec['citationNoteNum'] if spec.key? 'citationNoteNum' @hash = spec['citationHash'] if spec.key? 'citationHash' end |
Instance Attribute Details
#hash ⇒ Integer
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 72 73 |
# File 'lib/paru/filter/citation.rb', line 47 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.key? 'citationId' @prefix = Inline.new spec['citationPrefix'] if spec.key? 'citationPrefix' @suffix = Inline.new spec['citationSuffix'] if spec.key? 'citationSuffix' @mode = spec['citationMode'] if spec.key? 'citationMode' @note_num = spec['citationNoteNum'] if spec.key? 'citationNoteNum' @hash = spec['citationHash'] if spec.key? 'citationHash' end # Convert this Citation to an AST representation def to_ast citation = {} citation['citationId'] = @id unless @id.nil? citation['citationPrefix'] = @prefix.ast_contents unless @prefix.nil? citation['citationSuffix'] = @suffix.ast_contents unless @suffix.nil? citation['citationMode'] = @mode unless @mode.nil? citation['citationNoteNum'] = @note_num unless @note_num.nil? citation['citationHash'] = @hash unless @hash.nil? citation end end |
#id ⇒ String
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 72 73 |
# File 'lib/paru/filter/citation.rb', line 47 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.key? 'citationId' @prefix = Inline.new spec['citationPrefix'] if spec.key? 'citationPrefix' @suffix = Inline.new spec['citationSuffix'] if spec.key? 'citationSuffix' @mode = spec['citationMode'] if spec.key? 'citationMode' @note_num = spec['citationNoteNum'] if spec.key? 'citationNoteNum' @hash = spec['citationHash'] if spec.key? 'citationHash' end # Convert this Citation to an AST representation def to_ast citation = {} citation['citationId'] = @id unless @id.nil? citation['citationPrefix'] = @prefix.ast_contents unless @prefix.nil? citation['citationSuffix'] = @suffix.ast_contents unless @suffix.nil? citation['citationMode'] = @mode unless @mode.nil? citation['citationNoteNum'] = @note_num unless @note_num.nil? citation['citationHash'] = @hash unless @hash.nil? citation end end |
#mode ⇒ String
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 72 73 |
# File 'lib/paru/filter/citation.rb', line 47 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.key? 'citationId' @prefix = Inline.new spec['citationPrefix'] if spec.key? 'citationPrefix' @suffix = Inline.new spec['citationSuffix'] if spec.key? 'citationSuffix' @mode = spec['citationMode'] if spec.key? 'citationMode' @note_num = spec['citationNoteNum'] if spec.key? 'citationNoteNum' @hash = spec['citationHash'] if spec.key? 'citationHash' end # Convert this Citation to an AST representation def to_ast citation = {} citation['citationId'] = @id unless @id.nil? citation['citationPrefix'] = @prefix.ast_contents unless @prefix.nil? citation['citationSuffix'] = @suffix.ast_contents unless @suffix.nil? citation['citationMode'] = @mode unless @mode.nil? citation['citationNoteNum'] = @note_num unless @note_num.nil? citation['citationHash'] = @hash unless @hash.nil? citation end end |
#note_num ⇒ Integer
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 72 73 |
# File 'lib/paru/filter/citation.rb', line 47 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.key? 'citationId' @prefix = Inline.new spec['citationPrefix'] if spec.key? 'citationPrefix' @suffix = Inline.new spec['citationSuffix'] if spec.key? 'citationSuffix' @mode = spec['citationMode'] if spec.key? 'citationMode' @note_num = spec['citationNoteNum'] if spec.key? 'citationNoteNum' @hash = spec['citationHash'] if spec.key? 'citationHash' end # Convert this Citation to an AST representation def to_ast citation = {} citation['citationId'] = @id unless @id.nil? citation['citationPrefix'] = @prefix.ast_contents unless @prefix.nil? citation['citationSuffix'] = @suffix.ast_contents unless @suffix.nil? citation['citationMode'] = @mode unless @mode.nil? citation['citationNoteNum'] = @note_num unless @note_num.nil? citation['citationHash'] = @hash unless @hash.nil? citation end end |
#prefix ⇒ Array<Inline>
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 72 73 |
# File 'lib/paru/filter/citation.rb', line 47 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.key? 'citationId' @prefix = Inline.new spec['citationPrefix'] if spec.key? 'citationPrefix' @suffix = Inline.new spec['citationSuffix'] if spec.key? 'citationSuffix' @mode = spec['citationMode'] if spec.key? 'citationMode' @note_num = spec['citationNoteNum'] if spec.key? 'citationNoteNum' @hash = spec['citationHash'] if spec.key? 'citationHash' end # Convert this Citation to an AST representation def to_ast citation = {} citation['citationId'] = @id unless @id.nil? citation['citationPrefix'] = @prefix.ast_contents unless @prefix.nil? citation['citationSuffix'] = @suffix.ast_contents unless @suffix.nil? citation['citationMode'] = @mode unless @mode.nil? citation['citationNoteNum'] = @note_num unless @note_num.nil? citation['citationHash'] = @hash unless @hash.nil? citation end end |
#suffix ⇒ Array<Inline>
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 72 73 |
# File 'lib/paru/filter/citation.rb', line 47 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.key? 'citationId' @prefix = Inline.new spec['citationPrefix'] if spec.key? 'citationPrefix' @suffix = Inline.new spec['citationSuffix'] if spec.key? 'citationSuffix' @mode = spec['citationMode'] if spec.key? 'citationMode' @note_num = spec['citationNoteNum'] if spec.key? 'citationNoteNum' @hash = spec['citationHash'] if spec.key? 'citationHash' end # Convert this Citation to an AST representation def to_ast citation = {} citation['citationId'] = @id unless @id.nil? citation['citationPrefix'] = @prefix.ast_contents unless @prefix.nil? citation['citationSuffix'] = @suffix.ast_contents unless @suffix.nil? citation['citationMode'] = @mode unless @mode.nil? citation['citationNoteNum'] = @note_num unless @note_num.nil? citation['citationHash'] = @hash unless @hash.nil? citation end end |
Instance Method Details
#to_ast ⇒ Object
Convert this Citation to an AST representation
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/paru/filter/citation.rb', line 63 def to_ast citation = {} citation['citationId'] = @id unless @id.nil? citation['citationPrefix'] = @prefix.ast_contents unless @prefix.nil? citation['citationSuffix'] = @suffix.ast_contents unless @suffix.nil? citation['citationMode'] = @mode unless @mode.nil? citation['citationNoteNum'] = @note_num unless @note_num.nil? citation['citationHash'] = @hash unless @hash.nil? citation end |