Class: GirlsBar::Command::Confirm

Inherits:
Object
  • Object
show all
Defined in:
lib/girls_bar/command/confirm.rb

Instance Method Summary collapse

Constructor Details

#initialize(resource) ⇒ Confirm

Returns a new instance of Confirm.



5
6
7
8
9
# File 'lib/girls_bar/command/confirm.rb', line 5

def initialize(resource)
  @subject = resource["subject"]
  @selections = []
  register_selections resource["select"]
end

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/girls_bar/command/confirm.rb', line 11

def execute
  while true
    show_subject_and_selections
    key = GirlsBar::Filter.to_id gets
    case key
    when "exit", "quit"
      GirlsBar::Router.quit
    when "help"
      GirlsBar::Router.help
    else
      if selected = find_selection_by_key(key)
        GirlsBar::Router.move(selected.link)
        return true
      end
    end
    GirlsBar::Router.retry
  end
end