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



40
41
42
43
# File 'lib/paru/filter/code.rb', line 40

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

Instance Attribute Details

#attrAttr

Returns:



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
73
74
# File 'lib/paru/filter/code.rb', line 34

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)


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
73
74
# File 'lib/paru/filter/code.rb', line 34

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.



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

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

#has_inline?Boolean

Has this code node inline contents?

Returns:

  • (Boolean)

    false



63
64
65
# File 'lib/paru/filter/code.rb', line 63

def has_inline?
  false
end

#has_string?Boolean

Has this Code node a string contents?

Returns:

  • (Boolean)

    true



56
57
58
# File 'lib/paru/filter/code.rb', line 56

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



71
72
73
# File 'lib/paru/filter/code.rb', line 71

def markdown
  super.strip
end