Class: Cucumber::CucumberExpressions::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/ast.rb

Instance Method Summary collapse

Constructor Details

#initialize(type, nodes, token, start, _end) ⇒ Node

Returns a new instance of Node.



11
12
13
14
15
16
17
18
19
20
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/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

Instance Method Details

#endObject



38
39
40
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/ast.rb', line 38

def end
  @end
end

#nodesObject



26
27
28
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/ast.rb', line 26

def nodes
  @nodes
end

#startObject



34
35
36
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/ast.rb', line 34

def start
  @start
end

#textObject



42
43
44
45
46
47
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/ast.rb', line 42

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

#to_hashObject



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/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

#tokenObject



30
31
32
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/ast.rb', line 30

def token
  @token
end

#typeObject



22
23
24
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/ast.rb', line 22

def type
  @type
end