Class: AztroCli::CLI

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCLI

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_dataObject (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_signsObject (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_objectObject

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_signObject

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

#callObject



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'"
    menu
end

#colorObject



97
98
99
100
# File 'lib/aztro_cli/cli.rb', line 97

def color
    puts "#{user_object.color}"
    features
end

#compatibilityObject



87
88
89
90
# File 'lib/aztro_cli/cli.rb', line 87

def compatibility
      puts "#{user_object.compatibility}"
    features
end

#current_dateObject



82
83
84
85
# File 'lib/aztro_cli/cli.rb', line 82

def current_date
       puts "#{user_object.current_date}"
    menu
end

#featuresObject



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

#get_horoscopeObject



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

#goodbyeObject



123
124
125
126
# File 'lib/aztro_cli/cli.rb', line 123

def goodbye
    puts "Goodbye!"
    exit!
end

#invalidObject



133
134
135
136
# File 'lib/aztro_cli/cli.rb', line 133

def invalid
    puts "Invalid entry. Please try again."
    features
end

#invalid_entryObject



128
129
130
131
# File 'lib/aztro_cli/cli.rb', line 128

def invalid_entry
    puts "Invalid entry. Please try again."
    menu
end

#list_signsObject



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!"
menu
end

#lucky_numberObject



102
103
104
105
# File 'lib/aztro_cli/cli.rb', line 102

def lucky_number
    puts "#{user_object.lucky_number}"
    features
end

#lucky_timeObject



107
108
109
110
# File 'lib/aztro_cli/cli.rb', line 107

def lucky_time
    puts "#{user_object.lucky_time}"
    features
end


24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/aztro_cli/cli.rb', line 24

def menu
    input = gets.strip.downcase
    if input == "start"
        get_horoscope
    elsif input == "list"
        list_signs
    elsif input == "exit"
       goodbye
    else
        invalid_entry
    end
end

#moodObject



92
93
94
95
# File 'lib/aztro_cli/cli.rb', line 92

def mood
    puts "#{user_object.mood}"
    features
end