Class: Sevendigital::PriceDigestor
- Defined in:
- lib/sevendigital/digestion_tract/price_digestor.rb
Instance Method Summary collapse
-
#default_element_name ⇒ Object
:nodoc:.
- #default_list_element_name ⇒ Object
- #from_xml_doc(xml_node) ⇒ Object
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?
Constructor Details
This class inherits a constructor from Sevendigital::Digestor
Instance Method Details
#default_element_name ⇒ Object
:nodoc:
7 |
# File 'lib/sevendigital/digestion_tract/price_digestor.rb', line 7 def default_element_name; :price end |
#default_list_element_name ⇒ Object
8 |
# File 'lib/sevendigital/digestion_tract/price_digestor.rb', line 8 def default_list_element_name; nil end |
#from_xml_doc(xml_node) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sevendigital/digestion_tract/price_digestor.rb', line 10 def from_xml_doc(xml_node) make_sure_eating_nokogiri_node(xml_node) price = Sevendigital::Price.new() get_required_node(xml_node, "currency") do |c| price.currency_code = get_required_attribute(c, "code") {|v| v.upcase.to_sym} end price.currency_symbol = get_required_value(xml_node, "currency") price.value = get_required_value(xml_node,"value") {|v| v.to_d unless v.empty?} price.formatted_price = get_required_value(xml_node,"formattedPrice") price.rrp = get_optional_value(xml_node,"rrp") {|v| v.to_d unless v.empty?} price.formatted_rrp = get_optional_value(xml_node,"formattedRrp") price.on_sale = get_optional_value(xml_node,"onSale") {|v| v.downcase == "true"} price end |