Class: StrangerThingsDirectory::CLI

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

Instance Method Summary collapse

Instance Method Details

#callObject



3
4
5
6
7
# File 'lib/stranger_things_directory/cli.rb', line 3

def call
StrangerThingsDirectory::LocationScraper.new.send_locations
StrangerThingsDirectory::CharacterScraper.new.send_characters
welcome_message 
end

#character_info(character) ⇒ Object



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/stranger_things_directory/cli.rb', line 119

def character_info(character)
    puts ""
    puts "************ #{character.name} **************"
    puts ""
    puts "Status:           #{character.status}"
    puts "Gender:           #{character.gender}"   
    puts "Age:              #{character.age.join(" ")}"
    puts "Year Born:        #{character.born}"
    puts "Portrayed By:     #{character.actor}"
    puts "Residence(s):     #{character.residence.join(", ")}"
    puts "Affiliation(s):   #{character.affiliation.join(", ")}"
    puts "Occupation:       #{character.occupation.join(", ")}"
    puts "Family:           #{character.family.join(", ")}"
    puts "To learn more:    #{character.url}"
    puts "**********************************************"

    play
end

#character_listObject



98
99
100
101
102
103
104
105
106
107
# File 'lib/stranger_things_directory/cli.rb', line 98

def character_list
    puts ""
    puts "A list of characters currently trending will appear below. After, pick a number to learn more about that character in particular!"
    puts ""
    puts ">>>>>>>>>> Stranger Things Characters: <<<<<<<<<<<<<"
    StrangerThingsDirectory::Characters.all.each_with_index do |char, index|
        puts "#{index +1 }. #{char.name}"
    end
    pick_character
end

#exit_messageObject



138
139
140
# File 'lib/stranger_things_directory/cli.rb', line 138

def exit_message
        puts "Thanks for dropping in. Until next time "
end

#location_info(location) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/stranger_things_directory/cli.rb', line 82

def location_info(location)
    puts ""
    puts "*************** #{location.name} ***************"
    puts ""
    puts "Type:             #{location.type.join(" ")}"
    puts "Inhabitants:      #{location.inhabitants.join(", ")}"
    puts "Area:             #{location.area.join(", ")}"
    puts "To learn more:    #{location.url}"
    puts ""
    puts "About:            #{location.description}"
    puts "****************************************************"
   
    play 
    
end

#location_listObject



57
58
59
60
61
62
63
64
65
66
# File 'lib/stranger_things_directory/cli.rb', line 57

def location_list   
    puts ""
    puts "A list of popular locations from the show will appear below. After, pick a number to learn more about that location!"
    puts ""
    puts "------Stranger Things Locations:------"
    StrangerThingsDirectory::Locations.all.each_with_index do |location, index|
        puts "#{index +1}. #{location.name}"
    end
    pick_location
end

#pick_characterObject



109
110
111
112
113
114
115
116
117
# File 'lib/stranger_things_directory/cli.rb', line 109

def pick_character
    puts ""
    puts "What character would you like to learn more about? Enter their number: "

    input = gets.strip
    character = StrangerThingsDirectory::Characters.find(input.to_i)

    character_info(character)
end

#pick_locationObject



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/stranger_things_directory/cli.rb', line 68

def pick_location
    puts "What location would you like to learn more about? Enter the number: "
    input = gets.strip.to_i
    if input < StrangerThingsDirectory::Locations.all.length + 1 && input > 0
        location = StrangerThingsDirectory::Locations.find(input)

        location_info(location)
      
    else
        puts 'Try again'
        pick_location
    end
end

#playObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/stranger_things_directory/cli.rb', line 37

def play 
    puts ""
    puts "If you would like to see a list of trending characters enter 1, for locations enter 2. Or if you would like to exit, enter exit: "

    input = gets.strip

    case input
    when "1"
        character_list
    when "2"
        location_list
    when "exit"
        exit_message           
    else
        puts "I'm sorry, that didn't work. Try again!"
       play
    end

end

#welcome_messageObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/stranger_things_directory/cli.rb', line 9

def welcome_message
         
    puts "  .   *        .       . "
    puts " *      -0-                  "
    puts "     .                .  *       - )-"
    puts "   .      *       o       .       *"
    puts " o                |"
    puts "           .     -O-"
    puts ".                 |        *      .     -0-"
    puts "       *  o     .    '       *      .        o"
    puts "             .         .        |      *"
    puts "   *             *              -O-          ."
    puts "         .             *         |     ,"
    puts "                .           o"
    puts "        .---."
    puts "  =   _/__~0_\_     .  *            o       '"
    puts " = = (_________)             ."
    puts "                 .                        *"
    puts "       *               - ) -       *      "
    puts ""       
  
    puts ""
    puts "Welcome to the Stranger Things character and location directory!"
    puts ""
   
    play
end