Module: Taxplorer::Find

Included in:
Application
Defined in:
lib/taxplorer/find.rb

Instance Method Summary collapse

Instance Method Details

#get_children(node_id) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/taxplorer/find.rb', line 29

def get_children(node_id)
  node = @section[:elements].values.find {|e| e[:label] == node_id}
  nodes = @section[:elements].values.select {|e| e[:parent] == node_id}
  if nodes.any?
    child_nodes_prompt(nodes)
  else
    puts "no children"
    node_commands(node_id)
  end
end

#get_info(node_label) ⇒ Object



13
14
15
16
17
# File 'lib/taxplorer/find.rb', line 13

def get_info(node_label)
  info = @records["elements"].find {|s| s[:id] == node_label}
  puts Hirb::Helpers::AutoTable.render(info[:details])
  node_commands(node_label)
end

#get_parent(node) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/taxplorer/find.rb', line 19

def get_parent(node)
  child = @section[:elements].values.find {|e| e[:label] == node}
  parent = @section[:elements].values.find {|p| p[:label] == child[:parent]} if child
  if parent
    node_commands(parent[:label])
  else
    menu_prompt
  end
end

#get_section(section_name) ⇒ Object



8
9
10
11
# File 'lib/taxplorer/find.rb', line 8

def get_section(section_name)
  @section = @records["sections"].find {|s| s[:name] == section_name}
  @section[:elements].values.select {|e| e.parent == nil}
end

#get_sectionsObject



4
5
6
# File 'lib/taxplorer/find.rb', line 4

def get_sections
  @records["sections"].map {|s| s[:name]}
end