Class: AnimalInfo::Animal
- Inherits:
-
Object
- Object
- AnimalInfo::Animal
- Defined in:
- lib/animal.rb
Instance Attribute Summary collapse
-
#kingdom ⇒ Object
Returns the value of attribute kingdom.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#name ⇒ Object
Returns the value of attribute name.
-
#order ⇒ Object
Returns the value of attribute order.
-
#phylum ⇒ Object
Returns the value of attribute phylum.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Attribute Details
#kingdom ⇒ Object
Returns the value of attribute kingdom.
2 3 4 |
# File 'lib/animal.rb', line 2 def kingdom @kingdom end |
#klass ⇒ Object
Returns the value of attribute klass.
2 3 4 |
# File 'lib/animal.rb', line 2 def klass @klass end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/animal.rb', line 2 def name @name end |
#order ⇒ Object
Returns the value of attribute order.
2 3 4 |
# File 'lib/animal.rb', line 2 def order @order end |
#phylum ⇒ Object
Returns the value of attribute phylum.
2 3 4 |
# File 'lib/animal.rb', line 2 def phylum @phylum end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/animal.rb', line 2 def url @url end |
Class Method Details
.new_from_wikipedia(name) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/animal.rb', line 4 def self.new_from_wikipedia(name) properties = AnimalInfo::Scraper.scrape_from_wikipedia(normalize_name(name)) new.tap do |animal| properties.each do |property,value| animal.send("#{property}=", value) end end end |
.normalize_name(name) ⇒ Object
14 15 16 |
# File 'lib/animal.rb', line 14 def self.normalize_name(name) name.gsub(" ", "_").downcase end |