Class: BlueCrossPets::Dog
Overview
require_relative “./pet”
Constant Summary collapse
- @@dogs =
[]
Instance Attribute Summary
Attributes inherited from Pet
#age, #availability, #bio, #breed, #breed_and_colour, #can_live_with, #gender, #name, #profile_url, #reference
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(pet_hash) ⇒ Dog
constructor
A new instance of Dog.
Methods inherited from Pet
#add_attributes, create_from_index, #get_more_info
Constructor Details
#initialize(pet_hash) ⇒ Dog
Returns a new instance of Dog.
7 8 9 10 11 12 13 |
# File 'lib/blue_cross_pets/dog.rb', line 7 def initialize(pet_hash) pet_hash.each do |attribute, value| self.send("#{attribute}=".to_sym, value) end @@dogs << self end |
Class Method Details
.all ⇒ Object
15 16 17 |
# File 'lib/blue_cross_pets/dog.rb', line 15 def self.all @@dogs end |
.create_dogs ⇒ Object
23 24 25 26 27 28 |
# File 'lib/blue_cross_pets/dog.rb', line 23 def self.create_dogs if all.length == 0 dog_array = BlueCrossPets::Scraper.new.scrape_index("https://www.bluecross.org.uk/rehome/dog") create_from_index(dog_array) end end |
.sorted_array ⇒ Object
19 20 21 |
# File 'lib/blue_cross_pets/dog.rb', line 19 def self.sorted_array self.all.sort { |dog1, dog2| dog1.name <=> dog2.name } end |