Class: BlueCrossPets::Cat

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

Overview

require_relative “./pet”

Constant Summary collapse

@@cats =
[]

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) ⇒ Cat

Returns a new instance of Cat.



7
8
9
10
11
12
13
# File 'lib/blue_cross_pets/cat.rb', line 7

def initialize(pet_hash)
  pet_hash.each do |attribute, value|
    self.send("#{attribute}=".to_sym, value)
  end

  @@cats << self
end

Class Method Details

.allObject



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

def self.all
  @@cats
end

.create_catsObject



19
20
21
22
23
24
# File 'lib/blue_cross_pets/cat.rb', line 19

def self.create_cats
  if all.length == 0
    cat_array = BlueCrossPets::Scraper.new.scrape_index("https://www.bluecross.org.uk/rehome/cat")
    create_from_index(cat_array)
  end
end