Class: Peddler::Parsers::Model
- Inherits:
-
XML
- Object
- Base
- XML
- Peddler::Parsers::Model
show all
- Includes:
- Structure
- Defined in:
- lib/peddler/parsers/model.rb
Direct Known Subclasses
MWS::Feeds::Parsers::Feed, MWS::Feeds::Parsers::FeedSubmission, MWS::Feeds::Parsers::FeedSubmissionCount, MWS::Feeds::Parsers::FeedSubmissions, MWS::Orders::Parser::InvoiceData, MWS::Orders::Parsers::Order, MWS::Orders::Parsers::OrderItem, MWS::Orders::Parsers::PaymentExecutionDetailItem, MWS::Orders::Parsers::ServiceStatus, MWS::Orders::Parsers::ServiceStatusMessage, MWS::Orders::Parsers::ShippingAddress
Instance Attribute Summary
Attributes inherited from Base
#document
Instance Method Summary
collapse
Methods inherited from XML
#at_xpath, handle?, #xpath
Methods inherited from Base
handle?, #initialize
Instance Method Details
#float_at_xpath(path) ⇒ Object
13
14
15
16
|
# File 'lib/peddler/parsers/model.rb', line 13
def float_at_xpath(path)
str = text_at_xpath(path)
str.to_f if str
end
|
#integer_at_xpath(path) ⇒ Object
18
19
20
21
|
# File 'lib/peddler/parsers/model.rb', line 18
def integer_at_xpath(path)
str = text_at_xpath(path)
str.to_i if str
end
|
#money_at_xpath(path) ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/peddler/parsers/model.rb', line 23
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
|
#text_at_xpath(path) ⇒ Object
32
33
34
35
|
# File 'lib/peddler/parsers/model.rb', line 32
def text_at_xpath(path)
node = at_xpath(path)
node.text if node
end
|
#time_at_xpath(path) ⇒ Object
37
38
39
40
|
# File 'lib/peddler/parsers/model.rb', line 37
def time_at_xpath(path)
str = text_at_xpath(path)
Time.parse(CGI.unescape(str)) if str
end
|