Class: PetFinder::Pet
- Inherits:
-
Object
- Object
- PetFinder::Pet
- Defined in:
- lib/pet_finder/pet.rb
Instance Attribute Summary collapse
-
#age ⇒ Object
Returns the value of attribute age.
-
#animal ⇒ Object
Returns the value of attribute animal.
-
#breeds ⇒ Object
Returns the value of attribute breeds.
-
#contact ⇒ Object
Returns the value of attribute contact.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#lastUpdate ⇒ Object
Returns the value of attribute lastUpdate.
-
#media ⇒ Object
Returns the value of attribute media.
-
#mix ⇒ Object
Returns the value of attribute mix.
-
#name ⇒ Object
Returns the value of attribute name.
-
#sex ⇒ Object
Returns the value of attribute sex.
-
#shelterId ⇒ Object
Returns the value of attribute shelterId.
-
#size ⇒ Object
Returns the value of attribute size.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #get_photos ⇒ Object
-
#initialize(atts = {}) ⇒ Pet
constructor
A new instance of Pet.
Constructor Details
#initialize(atts = {}) ⇒ Pet
Returns a new instance of Pet.
6 7 8 9 10 |
# File 'lib/pet_finder/pet.rb', line 6 def initialize(atts={}) atts.each do |key, value| self.send("#{key}=", value) if respond_to?(key) end end |
Instance Attribute Details
#age ⇒ Object
Returns the value of attribute age.
4 5 6 |
# File 'lib/pet_finder/pet.rb', line 4 def age @age end |
#animal ⇒ Object
Returns the value of attribute animal.
4 5 6 |
# File 'lib/pet_finder/pet.rb', line 4 def animal @animal end |
#breeds ⇒ Object
Returns the value of attribute breeds.
4 5 6 |
# File 'lib/pet_finder/pet.rb', line 4 def breeds @breeds end |
#contact ⇒ Object
Returns the value of attribute contact.
4 5 6 |
# File 'lib/pet_finder/pet.rb', line 4 def contact @contact end |
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/pet_finder/pet.rb', line 4 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/pet_finder/pet.rb', line 4 def id @id end |
#lastUpdate ⇒ Object
Returns the value of attribute lastUpdate.
4 5 6 |
# File 'lib/pet_finder/pet.rb', line 4 def lastUpdate @lastUpdate end |
#media ⇒ Object
Returns the value of attribute media.
4 5 6 |
# File 'lib/pet_finder/pet.rb', line 4 def media @media end |
#mix ⇒ Object
Returns the value of attribute mix.
4 5 6 |
# File 'lib/pet_finder/pet.rb', line 4 def mix @mix end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/pet_finder/pet.rb', line 4 def name @name end |
#sex ⇒ Object
Returns the value of attribute sex.
4 5 6 |
# File 'lib/pet_finder/pet.rb', line 4 def sex @sex end |
#shelterId ⇒ Object
Returns the value of attribute shelterId.
4 5 6 |
# File 'lib/pet_finder/pet.rb', line 4 def shelterId @shelterId end |
#size ⇒ Object
Returns the value of attribute size.
4 5 6 |
# File 'lib/pet_finder/pet.rb', line 4 def size @size end |
#status ⇒ Object
Returns the value of attribute status.
4 5 6 |
# File 'lib/pet_finder/pet.rb', line 4 def status @status end |
Instance Method Details
#get_photos ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/pet_finder/pet.rb', line 12 def get_photos my_photos = {} photos = media['photos']['photo'] all_photos = [] 0..5.times do |x| all_photos << photos.select do |p| p_id = p.match(/([1-5])-\w+\.jpg$/)[1] p_id == x.to_s end end all_photos.each_with_index do |photo_array, idx| res_hash = { '500x500' => nil, 'max50_height' => nil, '300x250' => nil, 'max60_wide' => nil, 'max95_wide' => nil } photo_array.each do |photo_url| res_hash['500x500'] = photo_url if photo_url.match(/x\.jpg$/) res_hash['max50_height'] = photo_url if photo_url.match(/t\.jpg$/) res_hash['300x250'] = photo_url if photo_url.match(/pn\.jpg$/) res_hash['max60_wide'] = photo_url if photo_url.match(/pnt\.jpg$/) res_hash['max95_wide'] = photo_url if photo_url.match(/fpm\.jpg$/) end my_photos["photo_#{idx.to_s}"] = res_hash unless res_hash.values.compact.empty? end my_photos end |