Class: AnimalInfo::Controller
- Inherits:
-
Object
- Object
- AnimalInfo::Controller
- Defined in:
- lib/controller.rb
Instance Attribute Summary collapse
-
#animal_name ⇒ Object
readonly
Returns the value of attribute animal_name.
Instance Method Summary collapse
- #display_information ⇒ Object
-
#initialize(animal_name) ⇒ Controller
constructor
A new instance of Controller.
Constructor Details
#initialize(animal_name) ⇒ Controller
Returns a new instance of Controller.
4 5 6 7 |
# File 'lib/controller.rb', line 4 def initialize(animal_name) @animal_name = animal_name display_information end |
Instance Attribute Details
#animal_name ⇒ Object (readonly)
Returns the value of attribute animal_name.
2 3 4 |
# File 'lib/controller.rb', line 2 def animal_name @animal_name end |
Instance Method Details
#display_information ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/controller.rb', line 9 def display_information puts "Please wait while we fetch info for you!" begin animal = AnimalInfo::Animal.new_from_wikipedia(@animal_name) if animal.kingdom || animal.phylum || animal.klass || animal.order puts puts "Name: #{animal.name}" puts "Kingdom: #{animal.kingdom}" puts "Phylum: #{animal.phylum}" puts "Class: #{animal.klass}" puts "Order: #{animal.order}" puts "Source: #{animal.url}" else puts "Not Found!" end rescue puts "Not Found 404!" end end |