class Cucumber::CucumberExpressions::Node

def initialize(type, nodes, token, start, ending)

def initialize(type, nodes, token, start, ending)
  raise 'Either nodes or token must be defined' if nodes.nil? && token.nil?
  @type = type
  @nodes = nodes
  @token = token
  @start = start
  @end = ending
end

def text

def text
  return @nodes.map { |value| value.text }.join('') if @token.nil?
  @token
end

def to_hash

def to_hash
  hash = Hash.new
  hash['type'] = @type
  hash['nodes'] = @nodes.map { |node| node.to_hash } unless @nodes.nil?
  hash['token'] = @token unless @token.nil?
  hash['start'] = @start
  hash['end'] = @end
  hash
end