Module: Taxplorer::Command
- Included in:
- Application
- Defined in:
- lib/taxplorer/command.rb
Instance Method Summary collapse
- #child_nodes_prompt(nodes) ⇒ Object
- #clear ⇒ Object
- #load_shell ⇒ Object
- #menu_prompt ⇒ Object
- #node_commands(node) ⇒ Object
- #quit ⇒ Object
- #section_prompt(section_name) ⇒ Object
- #welcome_prompt ⇒ Object
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 || .prompt = "Select node" nodes.each do |s| .choice(s[:label]) { |s| node_commands(s)} end end end |
#clear ⇒ Object
76 77 78 |
# File 'lib/taxplorer/command.rb', line 76 def clear system "clear" or system "cls" end |
#load_shell ⇒ Object
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 |
#menu_prompt ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/taxplorer/command.rb', line 21 def clear choose do || .prompt = "Choose Taxonomy section" get_sections.each do |s| .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" when "tree" clear puts tree_view(node) puts "\n\n" node_commands(node) when "quit" quit end end |
#quit ⇒ Object
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 || .prompt = "Choose Heading" get_section(section_name).each do |s| .choice(s[:label]) { |s| node_commands(s)} end end end |
#welcome_prompt ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/taxplorer/command.rb', line 12 def welcome_prompt choose do || .prompt = "Choose preferred taxonomy" ["UK GAAP", "UK IFRS"].each do |t| .choice(t) { |c| say("have a glass of whiskey while we load up #{c} for you"); load_taxonomy } end end end |