Class: Cucumber::CucumberExpressions::Node
- Inherits:
-
Object
- Object
- Cucumber::CucumberExpressions::Node
- Defined in:
- lib/cucumber/cucumber_expressions/ast.rb
Instance Attribute Summary collapse
-
#end ⇒ Object
readonly
Returns the value of attribute end.
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type, nodes, token, start, ending) ⇒ Node
constructor
A new instance of Node.
- #text ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(type, nodes, token, start, ending) ⇒ Node
Returns a new instance of Node.
15 16 17 18 19 20 21 22 23 |
# File 'lib/cucumber/cucumber_expressions/ast.rb', line 15 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 |
Instance Attribute Details
#end ⇒ Object (readonly)
Returns the value of attribute end.
13 14 15 |
# File 'lib/cucumber/cucumber_expressions/ast.rb', line 13 def end @end end |
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
13 14 15 |
# File 'lib/cucumber/cucumber_expressions/ast.rb', line 13 def nodes @nodes end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
13 14 15 |
# File 'lib/cucumber/cucumber_expressions/ast.rb', line 13 def start @start end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
13 14 15 |
# File 'lib/cucumber/cucumber_expressions/ast.rb', line 13 def token @token end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
13 14 15 |
# File 'lib/cucumber/cucumber_expressions/ast.rb', line 13 def type @type end |
Instance Method Details
#text ⇒ Object
25 26 27 28 29 |
# File 'lib/cucumber/cucumber_expressions/ast.rb', line 25 def text return @nodes.map { |value| value.text }.join('') if @token.nil? @token end |
#to_hash ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/cucumber/cucumber_expressions/ast.rb', line 31 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 |