class Markie::Node

Attributes

children[R]
token_count[R]
type[R]
value[R]

Public Class Methods

new(type:, token_count:, children: [], value: nil) click to toggle source
# 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

Public Instance Methods

to_json() click to toggle source
# 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