Class: PetsSeekingPeople::Pets

Inherits:
Object
  • Object
show all
Defined in:
lib/pets_seeking_people/pets.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(animal_hash) ⇒ Pets

Returns a new instance of Pets.



7
8
9
10
# File 'lib/pets_seeking_people/pets.rb', line 7

def initialize(animal_hash)
  animal_hash.each {|key, value| self.send(("#{key}="), value)}
  @@all << self
end

Instance Attribute Details

#adoption_contactObject

Returns the value of attribute adoption_contact.



3
4
5
# File 'lib/pets_seeking_people/pets.rb', line 3

def adoption_contact
  @adoption_contact
end

#adoption_websiteObject

Returns the value of attribute adoption_website.



3
4
5
# File 'lib/pets_seeking_people/pets.rb', line 3

def adoption_website
  @adoption_website
end

#ageObject

Returns the value of attribute age.



3
4
5
# File 'lib/pets_seeking_people/pets.rb', line 3

def age
  @age
end

#animal_urlObject

Returns the value of attribute animal_url.



3
4
5
# File 'lib/pets_seeking_people/pets.rb', line 3

def animal_url
  @animal_url
end

#breedObject

Returns the value of attribute breed.



3
4
5
# File 'lib/pets_seeking_people/pets.rb', line 3

def breed
  @breed
end

#detailed_infoObject

Returns the value of attribute detailed_info.



3
4
5
# File 'lib/pets_seeking_people/pets.rb', line 3

def detailed_info
  @detailed_info
end

#genderObject

Returns the value of attribute gender.



3
4
5
# File 'lib/pets_seeking_people/pets.rb', line 3

def gender
  @gender
end

#infoObject

Returns the value of attribute info.



3
4
5
# File 'lib/pets_seeking_people/pets.rb', line 3

def info
  @info
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/pets_seeking_people/pets.rb', line 3

def name
  @name
end

Class Method Details

.allObject



23
24
25
# File 'lib/pets_seeking_people/pets.rb', line 23

def self.all
  @@all
end

.create_from_collection(animals_array) ⇒ Object



12
13
14
15
16
# File 'lib/pets_seeking_people/pets.rb', line 12

def self.create_from_collection(animals_array)
  animals_array.each do |animal|
    PetsSeekingPeople::Pets.new(animal)
  end
end

.find(input) ⇒ Object



27
28
29
# File 'lib/pets_seeking_people/pets.rb', line 27

def self.find(input)
  self.all[input.to_i-1]
end

Instance Method Details

#add_animal_attributes(attributes_hash) ⇒ Object



18
19
20
21
# File 'lib/pets_seeking_people/pets.rb', line 18

def add_animal_attributes(attributes_hash)
  attributes_hash.each {|key, value| self.send(("#{key}="), value)}
  self
end