Class: GitRecent::BranchChooser
- Inherits:
-
Object
- Object
- GitRecent::BranchChooser
- Defined in:
- lib/git_recent/branch_chooser.rb
Instance Method Summary collapse
-
#initialize(choices, input_stream = $stdin, output_stream = $stdout) ⇒ BranchChooser
constructor
A new instance of BranchChooser.
- #request_choice ⇒ Object
Constructor Details
#initialize(choices, input_stream = $stdin, output_stream = $stdout) ⇒ BranchChooser
Returns a new instance of BranchChooser.
9 10 11 12 13 |
# File 'lib/git_recent/branch_chooser.rb', line 9 def initialize(choices, input_stream=$stdin, output_stream=$stdout) @choices = choices @input_stream = input_stream @output_stream = output_stream end |
Instance Method Details
#request_choice ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/git_recent/branch_chooser.rb', line 15 def request_choice display_choices output_stream.print 'Please select a branch: ' input = input_stream.gets.strip choice_index = input.to_i - 1 return choices.fetch(choice_index) if valid_choice?(choice_index) nil end |