Class: ShippingScale::Response
- Inherits:
-
Object
- Object
- ShippingScale::Response
- Defined in:
- lib/shipping_scale/response.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
Returns the value of attribute raw.
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Class Method Summary collapse
Instance Method Summary collapse
- #details ⇒ Object
-
#initialize(xml) ⇒ Response
constructor
A new instance of Response.
- #price ⇒ Object
Constructor Details
#initialize(xml) ⇒ Response
Returns a new instance of Response.
13 14 15 |
# File 'lib/shipping_scale/response.rb', line 13 def initialize(xml) @xml = xml end |
Instance Attribute Details
#raw ⇒ Object
Returns the value of attribute raw.
3 4 5 |
# File 'lib/shipping_scale/response.rb', line 3 def raw @raw end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
17 18 19 |
# File 'lib/shipping_scale/response.rb', line 17 def xml @xml end |
Class Method Details
.parse(xml) ⇒ Object
6 7 8 9 10 |
# File 'lib/shipping_scale/response.rb', line 6 def parse(xml) response = self.new(xml) response.raw = xml response end |
Instance Method Details
#details ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/shipping_scale/response.rb', line 19 def details details = {} xml.search("Package").children.each do |node| details[node.name.snakecase.to_sym] = node.text end return details end |
#price ⇒ Object
29 30 31 |
# File 'lib/shipping_scale/response.rb', line 29 def price xml.search("Package").children.search("Postage").text.to_f end |