Module: Taxplorer::Command

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

Instance Method Summary collapse

Instance Method Details

#child_nodes_prompt(nodes) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/taxplorer/command.rb', line 41

def child_nodes_prompt(nodes)
  choose do |menu|
    menu.prompt = "Select node"
    nodes.each do |s|
      menu.choice(s[:label]) { |s| node_commands(s)}
    end
  end
end

#clearObject



76
77
78
# File 'lib/taxplorer/command.rb', line 76

def clear
  system "clear" or system "cls"
end

#load_shellObject



4
5
6
7
8
9
10
# File 'lib/taxplorer/command.rb', line 4

def load_shell
  loop do
    welcome_prompt
    break if @run == false
  end
  puts "bye bye"
end


21
22
23
24
25
26
27
28
29
# File 'lib/taxplorer/command.rb', line 21

def menu_prompt
  clear
  choose do |menu|
    menu.prompt = "Choose Taxonomy section"
    get_sections.each do |s|
      menu.choice(s) { |s| section_prompt(s)}
    end
  end
end

#node_commands(node) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/taxplorer/command.rb', line 50

def node_commands(node)
  puts "Viewing #{node}"
  cmd = ask("Enter command:  ", %w{info children parent menu tree quit}) {|q| q.readline = true}
  case cmd
  when "info"
    get_info(node)
  when "children"
    get_children(node)
  when "parent"
    get_parent(node)
  when "menu"
    menu_prompt
  when "tree"
    clear
    puts tree_view(node)
    puts "\n\n"
    node_commands(node)
  when "quit"
    quit
  end
end

#quitObject



72
73
74
# File 'lib/taxplorer/command.rb', line 72

def quit
  @run = false
end

#section_prompt(section_name) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/taxplorer/command.rb', line 31

def section_prompt(section_name)
  clear
  choose do |menu|
    menu.prompt = "Choose Heading"
    get_section(section_name).each do |s|
      menu.choice(s[:label]) { |s| node_commands(s)}
    end
  end
end

#welcome_promptObject



12
13
14
15
16
17
18
19
# File 'lib/taxplorer/command.rb', line 12

def welcome_prompt
  choose do |menu|
    menu.prompt = "Choose preferred taxonomy"
    ["UK GAAP", "UK IFRS"].each do |t|
      menu.choice(t) { |c| say("have a glass of whiskey while we load up #{c} for you"); load_taxonomy }
    end
  end
end