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
- VERSION =
'0.2.0'
Instance Method Summary
collapse
Instance Method Details
#execute(&block) ⇒ Object
25
26
27
|
# File 'lib/trees.rb', line 25
def execute(&block)
@current_line.execute = block
end
|
#line(path, &block) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/trees.rb', line 9
def line(path, &block)
current_path << path
@current_line = Line.new(path: current_path.join, params: block.parameters.to_h)
lines[current_path.join] = @current_line
trie.merge(line: @current_line)
block.call if block_given?
current_path.pop
end
|
#run(args) ⇒ Object
29
30
31
32
33
|
# File 'lib/trees.rb', line 29
def run(args)
results = trie.match(path: args.join(' '))
execute_block(results:)
end
|
#summary(&block) ⇒ Object
21
22
23
|
# File 'lib/trees.rb', line 21
def summary(&block)
@current_line.summary = block
end
|