class Cucumber::CucumberExpressions::Node

Public Class Methods

new(type, nodes, token, start, _end) click to toggle source
# File lib/cucumber/cucumber_expressions/ast.rb, line 11
def initialize(type, nodes, token, start, _end)
  if nodes.nil? && token.nil?
    raise 'Either nodes or token must be defined'
  end
  @type = type
  @nodes = nodes
  @token = token
  @start = start
  @end = _end
end

Public Instance Methods

end() click to toggle source
# File lib/cucumber/cucumber_expressions/ast.rb, line 38
def end
  @end
end
nodes() click to toggle source
# File lib/cucumber/cucumber_expressions/ast.rb, line 26
def nodes
  @nodes
end
start() click to toggle source
# File lib/cucumber/cucumber_expressions/ast.rb, line 34
def start
  @start
end
text() click to toggle source
# File lib/cucumber/cucumber_expressions/ast.rb, line 42
def text
  if @token.nil?
    return @nodes.map { |value| value.text }.join('')
  end
  @token
end
to_hash() click to toggle source
# File lib/cucumber/cucumber_expressions/ast.rb, line 49
def to_hash
  hash = Hash.new
  hash["type"] = @type
  unless @nodes.nil?
    hash["nodes"] = @nodes.map { |node| node.to_hash }
  end
  unless @token.nil?
    hash["token"] = @token
  end
  hash["start"] = @start
  hash["end"] = @end
  hash
end
token() click to toggle source
# File lib/cucumber/cucumber_expressions/ast.rb, line 30
def token
  @token
end
type() click to toggle source
# File lib/cucumber/cucumber_expressions/ast.rb, line 22
def type
  @type
end