Class: PetfinderV2::Serializers::Animal

Inherits:
Object
  • Object
show all
Defined in:
lib/petfinder_V2/serializers/animal.rb

Constant Summary collapse

NESTED_ATTRIBUTE_ATTS =
%w[
  declawed
  house_trained
  shots_current
  spayed_neutered
  special_needs
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Animal

Returns a new instance of Animal.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/petfinder_V2/serializers/animal.rb', line 46

def initialize(data)
  @data = data
  @age = data['age']
  @coat = data['coat']
  @contact = data['contact']
  @description = data['description']
  @gender = data['gender']
  @id = data['id']
  @name = data['name']
  @organization_id = data['organization_id']
  @photos = data['photos']
  @species = data['species']
  @size = data['size']
  @status = data['status']
  @type = data['type']
end

Instance Attribute Details

#ageObject (readonly)

Returns the value of attribute age.



33
34
35
# File 'lib/petfinder_V2/serializers/animal.rb', line 33

def age
  @age
end

#coatObject (readonly)

Returns the value of attribute coat.



33
34
35
# File 'lib/petfinder_V2/serializers/animal.rb', line 33

def coat
  @coat
end

#contactObject (readonly)

Returns the value of attribute contact.



33
34
35
# File 'lib/petfinder_V2/serializers/animal.rb', line 33

def contact
  @contact
end

#descriptionObject (readonly)

Returns the value of attribute description.



33
34
35
# File 'lib/petfinder_V2/serializers/animal.rb', line 33

def description
  @description
end

#genderObject (readonly)

Returns the value of attribute gender.



33
34
35
# File 'lib/petfinder_V2/serializers/animal.rb', line 33

def gender
  @gender
end

#idObject (readonly)

Returns the value of attribute id.



33
34
35
# File 'lib/petfinder_V2/serializers/animal.rb', line 33

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



33
34
35
# File 'lib/petfinder_V2/serializers/animal.rb', line 33

def name
  @name
end

#organization_idObject (readonly)

Returns the value of attribute organization_id.



33
34
35
# File 'lib/petfinder_V2/serializers/animal.rb', line 33

def organization_id
  @organization_id
end

#sizeObject (readonly)

Returns the value of attribute size.



33
34
35
# File 'lib/petfinder_V2/serializers/animal.rb', line 33

def size
  @size
end

#speciesObject (readonly)

Returns the value of attribute species.



33
34
35
# File 'lib/petfinder_V2/serializers/animal.rb', line 33

def species
  @species
end

#statusObject (readonly)

Returns the value of attribute status.



33
34
35
# File 'lib/petfinder_V2/serializers/animal.rb', line 33

def status
  @status
end

#typeObject (readonly)

Returns the value of attribute type.



33
34
35
# File 'lib/petfinder_V2/serializers/animal.rb', line 33

def type
  @type
end

Class Method Details

.process_collection(data) ⇒ Object



26
27
28
29
30
31
# File 'lib/petfinder_V2/serializers/animal.rb', line 26

def self.process_collection(data)
  {
    pagination: PetfinderV2::Serializers::Pagination.new(data['pagination']),
    animals: data['animals'].map { |d| new(d) }
  }
end

Instance Method Details

#breedsObject



71
72
73
# File 'lib/petfinder_V2/serializers/animal.rb', line 71

def breeds
  Breed.new(@data['breeds'])
end

#full_responseObject



67
68
69
# File 'lib/petfinder_V2/serializers/animal.rb', line 67

def full_response
  @data
end


83
84
85
# File 'lib/petfinder_V2/serializers/animal.rb', line 83

def link
  @data['_links']['self']['href']
end


87
88
89
# File 'lib/petfinder_V2/serializers/animal.rb', line 87

def organization_link
  @data['_links']['organization']['href']
end

#photosObject



79
80
81
# File 'lib/petfinder_V2/serializers/animal.rb', line 79

def photos
  Photos.process_collection(@data['photos'])
end