Class: Sevendigital::TrackDigestor
- Inherits:
-
Digestor
- Object
- Digestor
- Sevendigital::TrackDigestor
show all
- Defined in:
- lib/sevendigital/digestion_tract/track_digestor.rb
Instance Method Summary
collapse
Methods inherited from Digestor
#content_present?, #from_xml_string, #get_optional_attribute, #get_optional_node, #get_optional_value, #get_required_attribute, #get_required_node, #get_required_value, #initialize, #list_from_xml_doc, #list_from_xml_string, #make_sure_eating_nokogiri_node, #nested_list_from_xml_doc, #nested_list_from_xml_string, #paginate_results, #value_present?
Instance Method Details
#default_element_name ⇒ Object
6
|
# File 'lib/sevendigital/digestion_tract/track_digestor.rb', line 6
def default_element_name; :track end
|
#default_list_element_name ⇒ Object
7
|
# File 'lib/sevendigital/digestion_tract/track_digestor.rb', line 7
def default_list_element_name; :tracks end
|
#from_xml_doc(xml_node) ⇒ Object
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/sevendigital/digestion_tract/track_digestor.rb', line 9
def from_xml_doc(xml_node)
make_sure_eating_nokogiri_node(xml_node)
track = Track.new(@api_client)
populate_required_properties(track, xml_node)
populate_optional_properties(track, xml_node)
track
end
|
#populate_optional_properties(track, xml_node) ⇒ Object
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/sevendigital/digestion_tract/track_digestor.rb', line 26
def populate_optional_properties(track, xml_node)
track.version = get_optional_value(xml_node, "version")
track.track_number = get_optional_value(xml_node, "trackNumber") {|v| v.to_i}
track.duration = get_optional_value(xml_node, "duration") {|v| v.to_i}
track.release = get_optional_node(xml_node, "release") {|v |@api_client.release_digestor.from_xml_doc(v)}
track.explicit_content = get_optional_value(xml_node, "explicitContent") {|v| v.downcase == "true"}
track.isrc = get_optional_value(xml_node, "isrc")
track.url = get_optional_value(xml_node, "url")
track.price = get_optional_node(xml_node, "price") {|v| @api_client.price_digestor.from_xml_doc(v)}
end
|
#populate_required_properties(track, xml_node) ⇒ Object
20
21
22
23
24
|
# File 'lib/sevendigital/digestion_tract/track_digestor.rb', line 20
def populate_required_properties(track, xml_node)
track.id = get_required_attribute(xml_node, "id").to_i
track.title = get_required_value(xml_node, "title")
track.artist = get_required_node(xml_node, "artist") {|v| @api_client.artist_digestor.from_xml_doc(v) }
end
|