class GirlsBar::Command::Confirm
Public Class Methods
new(resource)
click to toggle source
# File lib/girls_bar/command/confirm.rb, line 4 def initialize(resource) @subject = resource["subject"] @selections = [] register_selections resource["select"] end
Public Instance Methods
execute()
click to toggle source
# File lib/girls_bar/command/confirm.rb, line 10 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
Private Instance Methods
find_selection_by_key(key)
click to toggle source
# File lib/girls_bar/command/confirm.rb, line 49 def find_selection_by_key(key) @selections.find {|x| x.key == key } end
register_selections(resource)
click to toggle source
# File lib/girls_bar/command/confirm.rb, line 30 def register_selections(resource) resource.each do |id, content| @selections << GirlsBar::Selection.new(id, content["label"], content["link"]) end end
show_subject_and_selections()
click to toggle source
# File lib/girls_bar/command/confirm.rb, line 36 def show_subject_and_selections GirlsBar::Helper.set_color(:white) { print "\n" puts GirlsBar::Filter.to_subject @subject puts GirlsBar::Settings.delimiter @selections.each do |selection| puts " #{selection.key}: " + GirlsBar::Filter.to_selection(selection.label) end puts GirlsBar::Settings.delimiter } print GirlsBar::Settings.prompt end