Class: Csvtool::Interface::CLI::MenuLoop
- Inherits:
-
Object
- Object
- Csvtool::Interface::CLI::MenuLoop
- Defined in:
- lib/csvtool/interface/cli/menu_loop.rb
Instance Method Summary collapse
-
#initialize(stdin:, stdout:, stderr: stdout, menu_options:, extract_column_action:, extract_rows_action:, randomize_rows_action:, dedupe_action:, parity_action:, split_action:, stats_action:) ⇒ MenuLoop
constructor
A new instance of MenuLoop.
- #run ⇒ Object
Constructor Details
#initialize(stdin:, stdout:, stderr: stdout, menu_options:, extract_column_action:, extract_rows_action:, randomize_rows_action:, dedupe_action:, parity_action:, split_action:, stats_action:) ⇒ MenuLoop
Returns a new instance of MenuLoop.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/csvtool/interface/cli/menu_loop.rb', line 7 def initialize(stdin:, stdout:, stderr: stdout, menu_options:, extract_column_action:, extract_rows_action:, randomize_rows_action:, dedupe_action:, parity_action:, split_action:, stats_action:) @stdin = stdin @stdout = stdout @stderr = stderr @menu_options = @extract_column_action = extract_column_action @extract_rows_action = extract_rows_action @randomize_rows_action = randomize_rows_action @dedupe_action = dedupe_action @parity_action = parity_action @split_action = split_action @stats_action = stats_action end |
Instance Method Details
#run ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/csvtool/interface/cli/menu_loop.rb', line 21 def run loop do @stderr.print "> " choice = @stdin.gets return 0 if choice.nil? case choice.strip when "1" @extract_column_action.call when "2" @extract_rows_action.call when "3" @randomize_rows_action.call when "4" @dedupe_action.call when "5" @parity_action.call when "6" @split_action.call when "7" @stats_action.call when "8" return 0 else @stderr.puts "Please choose 1, 2, 3, 4, 5, 6, 7, or 8." end end end |