Module: Trees
- Defined in:
- lib/line.rb,
lib/trie.rb,
lib/trees.rb,
lib/version.rb,
lib/trie_node.rb
Defined Under Namespace
Classes: Line, Trie, TrieNode
Constant Summary
collapse
- TOKEN_SEPARATOR =
' '.freeze
- VERSION =
'0.3.1'
Instance Method Summary
collapse
Instance Method Details
#execute(&block) ⇒ Object
29
30
31
|
# File 'lib/trees.rb', line 29
def execute(&block)
@current_line.execute = block
end
|
#line(path, &block) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/trees.rb', line 11
def line(path, &block)
current_path << path
current_path_joined = current_path.join(TOKEN_SEPARATOR)
@current_line = Line.new(path: current_path_joined, params: block.parameters.to_h)
lines[current_path_joined] = @current_line
trie.merge(line: @current_line)
block.call if block_given?
current_path.pop
end
|
#run(tokens) ⇒ Object
33
34
35
36
37
|
# File 'lib/trees.rb', line 33
def run(tokens)
results = trie.match(tokens:)
execute_block(results:)
end
|
#summary(&block) ⇒ Object
25
26
27
|
# File 'lib/trees.rb', line 25
def summary(&block)
@current_line.summary = block
end
|