Class: AustinsTopYogaStudios::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/Austins_Top_Yoga_Studios/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#inputObject (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

#callObject



5
6
7
8
# File 'lib/Austins_Top_Yoga_Studios/cli.rb', line 5

def call
  menu
  goodbye
end

#goodbyeObject



40
41
42
# File 'lib/Austins_Top_Yoga_Studios/cli.rb', line 40

def goodbye
  puts "See you later! As always, namaste."
end

#list_studiosObject



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


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 menu
   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