Class: StrangerThingsDirectory::CLI
- Inherits:
-
Object
- Object
- StrangerThingsDirectory::CLI
- Defined in:
- lib/stranger_things_directory/cli.rb
Instance Method Summary collapse
- #call ⇒ Object
- #character_info(character) ⇒ Object
- #character_list ⇒ Object
- #exit_message ⇒ Object
- #location_info(location) ⇒ Object
- #location_list ⇒ Object
- #pick_character ⇒ Object
- #pick_location ⇒ Object
- #play ⇒ Object
- #welcome_message ⇒ Object
Instance Method Details
#call ⇒ Object
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 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_list ⇒ Object
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_message ⇒ Object
138 139 140 |
# File 'lib/stranger_things_directory/cli.rb', line 138 def 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_list ⇒ Object
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_character ⇒ Object
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_location ⇒ Object
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 |
#play ⇒ Object
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" else puts "I'm sorry, that didn't work. Try again!" play end end |
#welcome_message ⇒ Object
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 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 |