Class: BlueCrossPets::Dog

Inherits:
Pet
  • Object
show all
Defined in:
lib/blue_cross_pets/dog.rb

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

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

.allObject



15
16
17
# File 'lib/blue_cross_pets/dog.rb', line 15

def self.all
  @@dogs
end

.create_dogsObject



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_arrayObject



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