Class: Horoscopes::CLI
- Inherits:
-
Object
- Object
- Horoscopes::CLI
- Defined in:
- lib/horoscopes/cli.rb
Overview
CLI Controller
Instance Method Summary collapse
- #call ⇒ Object
- #goodbye ⇒ Object
- #horoscope_reading ⇒ Object
- #list_zodiac ⇒ Object
- #main_menu ⇒ Object
Instance Method Details
#call ⇒ Object
4 5 6 7 8 9 |
# File 'lib/horoscopes/cli.rb', line 4 def call puts "Welcome to daily horoscopes!" Horoscopes::Scraper.new.signs list_zodiac end |
#goodbye ⇒ Object
44 45 46 |
# File 'lib/horoscopes/cli.rb', line 44 def goodbye puts "Come back later for tomorrow's horoscopes! <3" end |
#horoscope_reading ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/horoscopes/cli.rb', line 30 def horoscope_reading puts "Please type menu for list of zodiac signs or exit to leave:" answer = gets.strip.downcase case answer when "exit" goodbye when "menu" list_zodiac else horoscope_reading end end |
#list_zodiac ⇒ Object
11 12 13 14 15 |
# File 'lib/horoscopes/cli.rb', line 11 def list_zodiac Horoscopes::Zodiacs.all.each.with_index(1) do |sign, index| puts "#{index}. #{sign.name}: #{sign.birthday}" end end |
#main_menu ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/horoscopes/cli.rb', line 17 def puts "Please enter the number of your zodiac sign from the list above:" input = gets.strip.to_i if input.between?(1, Horoscopes::Zodiacs.all.size) puts "Today's Reading:" puts Horoscopes::Scraper.new.reading[input - 1].reading horoscope_reading else puts "Looks like that doesn't exist in the stars..." end end |