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.



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

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.



3
4
5
# File 'lib/gherkin/ast_node.rb', line 3

def rule_type
  @rule_type
end

Instance Method Details

#add(rule_type, obj) ⇒ Object



10
11
12
# File 'lib/gherkin/ast_node.rb', line 10

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

#get_items(rule_type) ⇒ Object



18
19
20
# File 'lib/gherkin/ast_node.rb', line 18

def get_items(rule_type)
  @_sub_items[rule_type]
end

#get_single(rule_type) ⇒ Object



14
15
16
# File 'lib/gherkin/ast_node.rb', line 14

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

#get_token(token_type) ⇒ Object



22
23
24
# File 'lib/gherkin/ast_node.rb', line 22

def get_token(token_type)
  get_single(token_type)
end

#get_tokens(token_type) ⇒ Object



26
27
28
# File 'lib/gherkin/ast_node.rb', line 26

def get_tokens(token_type)
  @_sub_items[token_type]
end