Sha256: 42addc673af910819199dcbff0b29eba5e809666c2e9bd8fc565d569f635788b
Contents?: true
Size: 883 Bytes
Versions: 4
Compression:
Stored size: 883 Bytes
Contents
require 'cgi' require 'time' require 'money' require 'structure' require 'peddler/parsers/xml' module Peddler module Parsers class Model < XML include Structure def float_at_xpath(path) str = text_at_xpath(path) str.to_f if str end def integer_at_xpath(path) str = text_at_xpath(path) str.to_i if str end def money_at_xpath(path) return unless amount = float_at_xpath("#{path}/Amount") currency_code = text_at_xpath("#{path}/CurrencyCode") amount = amount * 100 unless currency_code == 'JPY' Money.new(amount, currency_code) end def text_at_xpath(path) node = at_xpath(path) node.text if node end def time_at_xpath(path) str = text_at_xpath(path) Time.parse(CGI.unescape(str)) if str end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
peddler-0.6.3 | lib/peddler/parsers/model.rb |
peddler-0.6.2 | lib/peddler/parsers/model.rb |
peddler-0.6.1 | lib/peddler/parsers/model.rb |
peddler-0.6.0 | lib/peddler/parsers/model.rb |