Class: RChoice::CommandLineChooser
- Defined in:
- lib/rchoice/choosers/command_line_chooser.rb
Instance Method Summary collapse
- #call(choice) ⇒ Object
- #get_choice(choice) ⇒ Object
- #get_choice_num ⇒ Object
- #print_line(ln) ⇒ Object
Instance Method Details
#call(choice) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/rchoice/choosers/command_line_chooser.rb', line 3 def call(choice) print_line "Choose #{choice.name}" choice..each_with_index do |op,i| print_line "#{i}. #{choice.option_presenter[op]}" end get_choice(choice) end |
#get_choice(choice) ⇒ Object
13 14 15 |
# File 'lib/rchoice/choosers/command_line_chooser.rb', line 13 def get_choice(choice) choice.[get_choice_num] end |
#get_choice_num ⇒ Object
16 17 18 |
# File 'lib/rchoice/choosers/command_line_chooser.rb', line 16 def get_choice_num STDIN.gets.safe_to_i end |
#print_line(ln) ⇒ Object
10 11 12 |
# File 'lib/rchoice/choosers/command_line_chooser.rb', line 10 def print_line(ln) puts ln end |