Sha256: 2c7f75b950e39febd76c82e8ee4186e961860be5e8eec9cefcf0a37e2573081a

Contents?: true

Size: 803 Bytes

Versions: 1

Compression:

Stored size: 803 Bytes

Contents

require 'rational'
module Sevendigital

  class PriceDigestor < Digestor

    def default_element_name; :price end
    def default_list_element_name; nil end
  
    def from_proxy(price_proxy)
        make_sure_not_eating_nil(price_proxy)
        price = Sevendigital::Price.new()
        price.currency_code = price_proxy.currency.code.to_s.upcase.to_sym
        price.currency_symbol= price_proxy.currency.value
        price.value= price_proxy.value.value.to_f
        price.formatted_price= price_proxy.formatted_price.value
        price.rrp= price_proxy.rrp.value.to_f if price_proxy.rrp
        price.formatted_rrp= price_proxy.formatted_rrp.value if price_proxy.formatted_rrp
        price.on_sale = price_proxy.on_sale.value.to_s.downcase == "true"

        return price
      end

    end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
7digital-0.0.1 lib/sevendigital/digestion_tract/price_digestor.rb