Class: Markie::Node
- Inherits:
-
Object
- Object
- Markie::Node
- Defined in:
- lib/markie/node.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#token_count ⇒ Object
readonly
Returns the value of attribute token_count.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(type:, token_count:, children: [], value: nil) ⇒ Node
constructor
A new instance of Node.
- #to_json ⇒ Object
Constructor Details
#initialize(type:, token_count:, children: [], value: nil) ⇒ Node
Returns a new instance of Node.
4 5 6 7 8 9 |
# File 'lib/markie/node.rb', line 4 def initialize(type:, token_count:, children: [], value: nil) @type = type @token_count = token_count @children = children @value = value end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
3 4 5 |
# File 'lib/markie/node.rb', line 3 def children @children end |
#token_count ⇒ Object (readonly)
Returns the value of attribute token_count.
3 4 5 |
# File 'lib/markie/node.rb', line 3 def token_count @token_count end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/markie/node.rb', line 3 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
3 4 5 |
# File 'lib/markie/node.rb', line 3 def value @value end |
Instance Method Details
#to_json ⇒ Object
11 12 13 |
# File 'lib/markie/node.rb', line 11 def to_json "{ \"type\": \"#{type}\", \"token_count\": \"#{token_count}\", \"value\": \"#{value}\", \"children\": [#{children.map(&:to_json).join(", ") if children.any?}] }" end |