Class: Petfinder::Pet

Inherits:
Object
  • Object
show all
Extended by:
XmlMapper
Defined in:
lib/petfinder/pet.rb

Defined Under Namespace

Classes: Photo

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from XmlMapper

camel_case_lower, xml_attribute, xml_attributes

Constructor Details

#initialize(xml) ⇒ Pet

Returns a new instance of Pet.



10
11
12
# File 'lib/petfinder/pet.rb', line 10

def initialize(xml)
  @xml = xml
end

Instance Attribute Details

#photosObject (readonly)

Returns the value of attribute photos.



8
9
10
# File 'lib/petfinder/pet.rb', line 8

def photos
  @photos
end

Class Method Details

.multiple(xml) ⇒ Object



14
15
16
17
18
# File 'lib/petfinder/pet.rb', line 14

def self.multiple(xml)
  xml.xpath("//pets/pet").map do |node|
    Pet.new(Nokogiri::XML(node.to_xml))
  end
end

Instance Method Details

#breedsObject



24
25
26
# File 'lib/petfinder/pet.rb', line 24

def breeds
  @xml.xpath("//pet/breeds/breed").map(&:text)
end

#description_sanitizedObject



20
21
22
# File 'lib/petfinder/pet.rb', line 20

def description_sanitized
  Nokogiri::HTML(CGI.unescapeHTML(description)).content
end

#optionsObject



28
29
30
# File 'lib/petfinder/pet.rb', line 28

def options
  @xml.xpath("//pet/options/option").map(&:text)
end