Class: Petfinder::Pet
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
#photos ⇒ Object
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
#breeds ⇒ Object
24
25
26
|
# File 'lib/petfinder/pet.rb', line 24
def breeds
@xml.xpath("//pet/breeds/breed").map(&:text)
end
|
#city ⇒ Object
32
33
34
|
# File 'lib/petfinder/pet.rb', line 32
def city
@xml.xpath("//pet/contact/city").map(&:text)
end
|
#description_sanitized ⇒ Object
20
21
22
|
# File 'lib/petfinder/pet.rb', line 20
def description_sanitized
Nokogiri::HTML(CGI.unescapeHTML(description)).content
end
|
#inspect ⇒ Object
41
42
43
|
# File 'lib/petfinder/pet.rb', line 41
def inspect
"#<Pet id: '#{id}', name: '#{name}', animal: '#{animal}', mix: '#{mix}', sex: '#{sex}'>"
end
|
#options ⇒ Object
28
29
30
|
# File 'lib/petfinder/pet.rb', line 28
def options
@xml.xpath("//pet/options/option").map(&:text)
end
|