Class: PetfinderV2::Serializers::Animal
- Inherits:
-
Object
- Object
- PetfinderV2::Serializers::Animal
- 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
-
#age ⇒ Object
readonly
Returns the value of attribute age.
-
#coat ⇒ Object
readonly
Returns the value of attribute coat.
-
#contact ⇒ Object
readonly
Returns the value of attribute contact.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#gender ⇒ Object
readonly
Returns the value of attribute gender.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#organization_id ⇒ Object
readonly
Returns the value of attribute organization_id.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#species ⇒ Object
readonly
Returns the value of attribute species.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #breeds ⇒ Object
- #full_response ⇒ Object
-
#initialize(data) ⇒ Animal
constructor
A new instance of Animal.
- #link ⇒ Object
- #organization_link ⇒ Object
- #photos ⇒ Object
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
#age ⇒ Object (readonly)
Returns the value of attribute age.
33 34 35 |
# File 'lib/petfinder_V2/serializers/animal.rb', line 33 def age @age end |
#coat ⇒ Object (readonly)
Returns the value of attribute coat.
33 34 35 |
# File 'lib/petfinder_V2/serializers/animal.rb', line 33 def coat @coat end |
#contact ⇒ Object (readonly)
Returns the value of attribute contact.
33 34 35 |
# File 'lib/petfinder_V2/serializers/animal.rb', line 33 def contact @contact end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
33 34 35 |
# File 'lib/petfinder_V2/serializers/animal.rb', line 33 def description @description end |
#gender ⇒ Object (readonly)
Returns the value of attribute gender.
33 34 35 |
# File 'lib/petfinder_V2/serializers/animal.rb', line 33 def gender @gender end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
33 34 35 |
# File 'lib/petfinder_V2/serializers/animal.rb', line 33 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
33 34 35 |
# File 'lib/petfinder_V2/serializers/animal.rb', line 33 def name @name end |
#organization_id ⇒ Object (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 |
#size ⇒ Object (readonly)
Returns the value of attribute size.
33 34 35 |
# File 'lib/petfinder_V2/serializers/animal.rb', line 33 def size @size end |
#species ⇒ Object (readonly)
Returns the value of attribute species.
33 34 35 |
# File 'lib/petfinder_V2/serializers/animal.rb', line 33 def species @species end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
33 34 35 |
# File 'lib/petfinder_V2/serializers/animal.rb', line 33 def status @status end |
#type ⇒ Object (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
#breeds ⇒ Object
71 72 73 |
# File 'lib/petfinder_V2/serializers/animal.rb', line 71 def breeds Breed.new(@data['breeds']) end |
#full_response ⇒ Object
67 68 69 |
# File 'lib/petfinder_V2/serializers/animal.rb', line 67 def full_response @data end |
#link ⇒ Object
83 84 85 |
# File 'lib/petfinder_V2/serializers/animal.rb', line 83 def link @data['_links']['self']['href'] end |
#organization_link ⇒ Object
87 88 89 |
# File 'lib/petfinder_V2/serializers/animal.rb', line 87 def organization_link @data['_links']['organization']['href'] end |
#photos ⇒ Object
79 80 81 |
# File 'lib/petfinder_V2/serializers/animal.rb', line 79 def photos Photos.process_collection(@data['photos']) end |