Class: AztroCli::CLI
- Inherits:
-
Object
- Object
- AztroCli::CLI
- Defined in:
- lib/aztro_cli/cli.rb
Instance Attribute Summary collapse
-
#api_data ⇒ Object
readonly
Returns the value of attribute api_data.
-
#sun_signs ⇒ Object
readonly
Returns the value of attribute sun_signs.
-
#user_object ⇒ Object
Returns the value of attribute user_object.
-
#user_sign ⇒ Object
Returns the value of attribute user_sign.
Instance Method Summary collapse
- #call ⇒ Object
- #color ⇒ Object
- #compatibility ⇒ Object
- #current_date ⇒ Object
- #features ⇒ Object
- #get_horoscope ⇒ Object
- #goodbye ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #invalid ⇒ Object
- #invalid_entry ⇒ Object
- #list_signs ⇒ Object
- #lucky_number ⇒ Object
- #lucky_time ⇒ Object
- #menu ⇒ Object
- #mood ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/aztro_cli/cli.rb', line 5 def initialize @sun_signs = ["aquarius", "pisces", "aries", "taurus", "gemini", "cancer", "leo", "virgo", "libra", "scorpio", "sagittarius", "capricorn"] @api_data = [] sun_signs.each do |sign| data = API.get_data(sign) sunsign_object = SunSign.new(sign, data) @api_data << sunsign_object end call end |
Instance Attribute Details
#api_data ⇒ Object (readonly)
Returns the value of attribute api_data.
3 4 5 |
# File 'lib/aztro_cli/cli.rb', line 3 def api_data @api_data end |
#sun_signs ⇒ Object (readonly)
Returns the value of attribute sun_signs.
3 4 5 |
# File 'lib/aztro_cli/cli.rb', line 3 def sun_signs @sun_signs end |
#user_object ⇒ Object
Returns the value of attribute user_object.
2 3 4 |
# File 'lib/aztro_cli/cli.rb', line 2 def user_object @user_object end |
#user_sign ⇒ Object
Returns the value of attribute user_sign.
2 3 4 |
# File 'lib/aztro_cli/cli.rb', line 2 def user_sign @user_sign end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/aztro_cli/cli.rb', line 16 def call puts "Welcome!" puts "To learn more about your sun sign, please enter 'start'" puts "To find your sun sign, please enter 'list'" puts "To exit, please enter 'exit'" end |
#color ⇒ Object
97 98 99 100 |
# File 'lib/aztro_cli/cli.rb', line 97 def color puts "#{user_object.color}" features end |
#compatibility ⇒ Object
87 88 89 90 |
# File 'lib/aztro_cli/cli.rb', line 87 def compatibility puts "#{user_object.compatibility}" features end |
#current_date ⇒ Object
82 83 84 85 |
# File 'lib/aztro_cli/cli.rb', line 82 def current_date puts "#{user_object.current_date}" end |
#features ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/aztro_cli/cli.rb', line 37 def features puts "To learn more about your sign, please enter: 'mood', 'compatibility', 'color', 'lucky number, 'lucky time', or 'exit'" input = gets.strip.downcase if input == "compatibility" compatibility elsif input == "mood" mood elsif input == "color" color elsif input == "lucky number" lucky_number elsif input == "lucky time" lucky_time elsif input == "exit" goodbye elsif invalid else end end |
#get_horoscope ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/aztro_cli/cli.rb', line 61 def get_horoscope puts "please enter your sign" input = gets.strip.downcase if (sun_signs.include?(input)) puts "That's a valid sign" @user_sign = input selected_sign = api_data.select do |sign| sign.sign_name == user_sign end puts selected_sign @user_object = selected_sign.first puts "#{user_object.date_range}, #{user_object.description}" features else puts "sorry, that's not a valid sign" get_horoscope() end end |
#goodbye ⇒ Object
123 124 125 126 |
# File 'lib/aztro_cli/cli.rb', line 123 def goodbye puts "Goodbye!" exit! end |
#invalid ⇒ Object
133 134 135 136 |
# File 'lib/aztro_cli/cli.rb', line 133 def invalid puts "Invalid entry. Please try again." features end |
#invalid_entry ⇒ Object
128 129 130 131 |
# File 'lib/aztro_cli/cli.rb', line 128 def invalid_entry puts "Invalid entry. Please try again." end |
#list_signs ⇒ Object
112 113 114 115 116 117 118 119 120 121 |
# File 'lib/aztro_cli/cli.rb', line 112 def list_signs api_data.each do |sign| puts "#{sign.sign_name} , #{sign.date_range}" end puts "====================================" puts "please enter 'start' to learn about your sign!" end |
#lucky_number ⇒ Object
102 103 104 105 |
# File 'lib/aztro_cli/cli.rb', line 102 def lucky_number puts "#{user_object.lucky_number}" features end |
#lucky_time ⇒ Object
107 108 109 110 |
# File 'lib/aztro_cli/cli.rb', line 107 def lucky_time puts "#{user_object.lucky_time}" features end |
#menu ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/aztro_cli/cli.rb', line 24 def input = gets.strip.downcase if input == "start" get_horoscope elsif input == "list" list_signs elsif input == "exit" goodbye else invalid_entry end end |
#mood ⇒ Object
92 93 94 95 |
# File 'lib/aztro_cli/cli.rb', line 92 def mood puts "#{user_object.mood}" features end |