lib/peddler/parsers/model.rb in peddler-0.6.3 vs lib/peddler/parsers/model.rb in peddler-0.6.4
- old
+ new
@@ -8,10 +8,14 @@
module Peddler
module Parsers
class Model < XML
include Structure
+ def boolean_at_xpath(path)
+ !!text_at_xpath(path).match(/true|yes/i)
+ end
+
def float_at_xpath(path)
str = text_at_xpath(path)
str.to_f if str
end
@@ -25,14 +29,9 @@
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