Class: Blirb::Coordinator
Constant Summary collapse
- DEFAULT_TASKS =
File.('../../../blirb_tasks/tasks.rb', __FILE__)
Instance Attribute Summary collapse
-
#current_task ⇒ Object
readonly
Returns the value of attribute current_task.
-
#tasks ⇒ Object
readonly
Returns the value of attribute tasks.
Instance Method Summary collapse
- #go ⇒ Object
-
#initialize(file_path = nil) ⇒ Coordinator
constructor
A new instance of Coordinator.
-
#menu ⇒ Object
displays menu, sets the current task.
Constructor Details
#initialize(file_path = nil) ⇒ Coordinator
Returns a new instance of Coordinator.
6 7 8 9 10 11 12 13 14 |
# File 'lib/blirb/coordinator.rb', line 6 def initialize file_path = nil @tasks = [] load_tasks file_path || DEFAULT_TASKS @current_task = nil blirb = self Object.class_eval do @blirb = blirb end end |
Instance Attribute Details
#current_task ⇒ Object (readonly)
Returns the value of attribute current_task.
3 4 5 |
# File 'lib/blirb/coordinator.rb', line 3 def current_task @current_task end |
#tasks ⇒ Object (readonly)
Returns the value of attribute tasks.
3 4 5 |
# File 'lib/blirb/coordinator.rb', line 3 def tasks @tasks end |
Instance Method Details
#go ⇒ Object
16 17 18 19 |
# File 'lib/blirb/coordinator.rb', line 16 def go IRB.start end |
#menu ⇒ Object
displays menu, sets the current task
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/blirb/coordinator.rb', line 22 def end_tutorial if remaining_tasks.empty? list_commands puts "\nPlease choose a task by entering task number (completed tasks will not appear):\n\n" list_tasks while true print "\n> " if integer?( (selection = gets.chomp) ) && @tasks[(selection = selection.to_i)] select_task selection break elsif selection == 'q' || selection == 'exit' # variety is the spice of life exit end puts "Sorry, I'm not sure what you're trying to do. Please do something different." end end |