Class: Paru::PandocFilter::Citation

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(spec) ⇒ Citation

Create a new Citation node base on an AST specification

Parameters:

  • spec (Hash)

    the specification of this citation



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

#hashInteger

Returns:

  • (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

#idString

Returns:

  • (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

#modeString

Returns:

  • (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_numInteger

Returns:

  • (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

#prefixArray<Inline>

Returns:



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

#suffixArray<Inline>

Returns:



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_astObject

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