Class: Gherkin::AstNode

Inherits:
Object
  • Object
show all
Defined in:
lib/gherkin/ast_node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rule_type) ⇒ AstNode

Returns a new instance of AstNode.



7
8
9
10
# File 'lib/gherkin/ast_node.rb', line 7

def initialize(rule_type)
  @rule_type = rule_type
  @_sub_items = Hash.new { |hash, key| hash[key] = [] } # returns [] for unknown key
end

Instance Attribute Details

#rule_typeObject (readonly)

Returns the value of attribute rule_type.



5
6
7
# File 'lib/gherkin/ast_node.rb', line 5

def rule_type
  @rule_type
end

Instance Method Details

#add(rule_type, obj) ⇒ Object



12
13
14
# File 'lib/gherkin/ast_node.rb', line 12

def add(rule_type, obj)
  @_sub_items[rule_type].push(obj)
end

#get_items(rule_type) ⇒ Object



20
21
22
# File 'lib/gherkin/ast_node.rb', line 20

def get_items(rule_type)
  @_sub_items[rule_type]
end

#get_single(rule_type) ⇒ Object



16
17
18
# File 'lib/gherkin/ast_node.rb', line 16

def get_single(rule_type)
  @_sub_items[rule_type].first
end

#get_token(token_type) ⇒ Object



24
25
26
# File 'lib/gherkin/ast_node.rb', line 24

def get_token(token_type)
  get_single(token_type)
end

#get_tokens(token_type) ⇒ Object



28
29
30
# File 'lib/gherkin/ast_node.rb', line 28

def get_tokens(token_type)
  @_sub_items[token_type]
end