Class: AustinsTopYogaStudios::CLI
- Inherits:
-
Object
- Object
- AustinsTopYogaStudios::CLI
- Defined in:
- lib/Austins_Top_Yoga_Studios/cli.rb
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
Instance Method Summary collapse
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
3 4 5 |
# File 'lib/Austins_Top_Yoga_Studios/cli.rb', line 3 def input @input end |
Instance Method Details
#call ⇒ Object
5 6 7 8 |
# File 'lib/Austins_Top_Yoga_Studios/cli.rb', line 5 def call goodbye end |
#goodbye ⇒ Object
40 41 42 |
# File 'lib/Austins_Top_Yoga_Studios/cli.rb', line 40 def goodbye puts "See you later! As always, namaste." end |
#list_studios ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/Austins_Top_Yoga_Studios/cli.rb', line 10 def list_studios puts "Here are 18 amazing yoga studios in Austin, Tx" sleep(1.8) @all_studios = AustinsTopYogaStudios::Studio.all @all_studios.each.with_index(1) do |s, index| puts "#{index}. #{s.name}" end end |
#menu ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/Austins_Top_Yoga_Studios/cli.rb', line 20 def while input != "exit" puts "" puts "Enter the number of which yoga studio you would like more information about or hit list to display the studios:" @input = gets.strip.downcase if input == "list" list_studios elsif input.to_i.between?(1, AustinsTopYogaStudios::Studio.all.length) the_studio = AustinsTopYogaStudios::Studio.all[input.to_i - 1] puts "#{the_studio.name} - #{the_studio.paragraph}" elsif input == "exit" break else puts "Do not understand what you mean... type 1-18 or type exit to exit" end end end |