class Cucumber::CucumberExpressions::Node

Attributes

end[R]
nodes[R]
start[R]
token[R]
type[R]

Public Class Methods

new(type, nodes, token, start, ending) click to toggle source
# File lib/cucumber/cucumber_expressions/ast.rb, line 14
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

Public Instance Methods

text() click to toggle source
# File lib/cucumber/cucumber_expressions/ast.rb, line 24
def text
  return @nodes.map { |value| value.text }.join('') if @token.nil?

  @token
end
to_hash() click to toggle source
# File lib/cucumber/cucumber_expressions/ast.rb, line 30
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