Class: Paru::PandocFilter::Code

Inherits:
Inline show all
Defined in:
lib/paru/filter/code.rb

Overview

A Code node, with an attribute object and the code itself as a string.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents) ⇒ Code

Create a new Code node

Parameters:

  • contents (Array)

    an array of the attribute and the code



38
39
40
41
# File 'lib/paru/filter/code.rb', line 38

def initialize(contents)
    @attr = Attr.new contents[0]
    @string = contents[1]
end

Instance Attribute Details

#attrAttr

Returns:



32
33
34
35
36
37
38
39
40
41
42
43
44
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
72
# File 'lib/paru/filter/code.rb', line 32

class Code < Inline
    attr_accessor :attr, :string

    # Create a new Code node
    #
    # @param contents [Array] an array of the attribute and the code
    def initialize(contents)
        @attr = Attr.new contents[0]
        @string = contents[1]
    end

    # Create an AST representation of this Code node.
    def ast_contents()
        [
            @attr.to_ast,
            @string
        ]
    end

    # Has this Code node a string contents?
    #
    # @return [Boolean] true
    def has_string?()
        true
    end

    # Has this code node inline contents?
    #
    # @return [Boolean] false
    def has_inline?()
        false
    end
    
    # Get the markdown representation of this Node, including the Node
    # itself.
    #
    # @return [String] the outer markdown representation of this Node
    def markdown()
        super.strip
    end
end

#stringString

Returns:

  • (String)


32
33
34
35
36
37
38
39
40
41
42
43
44
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
72
# File 'lib/paru/filter/code.rb', line 32

class Code < Inline
    attr_accessor :attr, :string

    # Create a new Code node
    #
    # @param contents [Array] an array of the attribute and the code
    def initialize(contents)
        @attr = Attr.new contents[0]
        @string = contents[1]
    end

    # Create an AST representation of this Code node.
    def ast_contents()
        [
            @attr.to_ast,
            @string
        ]
    end

    # Has this Code node a string contents?
    #
    # @return [Boolean] true
    def has_string?()
        true
    end

    # Has this code node inline contents?
    #
    # @return [Boolean] false
    def has_inline?()
        false
    end
    
    # Get the markdown representation of this Node, including the Node
    # itself.
    #
    # @return [String] the outer markdown representation of this Node
    def markdown()
        super.strip
    end
end

Instance Method Details

#ast_contentsObject

Create an AST representation of this Code node.



44
45
46
47
48
49
# File 'lib/paru/filter/code.rb', line 44

def ast_contents()
    [
        @attr.to_ast,
        @string
    ]
end

#has_inline?Boolean

Has this code node inline contents?

Returns:

  • (Boolean)

    false



61
62
63
# File 'lib/paru/filter/code.rb', line 61

def has_inline?()
    false
end

#has_string?Boolean

Has this Code node a string contents?

Returns:

  • (Boolean)

    true



54
55
56
# File 'lib/paru/filter/code.rb', line 54

def has_string?()
    true
end

#markdownString

Get the markdown representation of this Node, including the Node itself.

Returns:

  • (String)

    the outer markdown representation of this Node



69
70
71
# File 'lib/paru/filter/code.rb', line 69

def markdown()
    super.strip
end