Sha256: bd3edff5acdef8ffff3b11dd2b9efbe00f470e7416ff8e6915f707949e4187da
Contents?: true
Size: 899 Bytes
Versions: 1
Compression:
Stored size: 899 Bytes
Contents
# frozen_string_literal: true module FriendlyShipping module Services class Ups class ParseModifierElement # @param [Nokogiri::XML::Element] element The modifier element from the source XML # @param [String] currency_code The currency code for this modifier's amount (i.e. 'USD') # @return [Array<String, Money>] def self.call(element, currency_code:) return unless element amount = element.at('Amount').text.to_d return if amount.zero? currency = Money::Currency.new(currency_code) amount = Money.new(amount * currency.subunit_to_unit, currency) modifier_type = element.at('ModifierType').text modifier_description = element.at('ModifierDesc').text label = "#{modifier_type} (#{modifier_description})" [label, amount] end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
friendly_shipping-0.9.0 | lib/friendly_shipping/services/ups/parse_modifier_element.rb |