Guest User

Untitled

a guest
Apr 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. class Order < ActiveResource::Base
  2. self.site = ''
  3. end
  4.  
  5. o = Order.new(:price => 6.47)
  6. o.to_xml
  7. # => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<order>\n <price type=\"float\">6.47</price>\n</order>\n"
  8.  
  9. o = Order.new(:price => BigDecimal.new('6.47'))
  10. o.to_xml
  11. #=> "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<order>\n <price type=\"decimal\">6.47</price>\n</order>\n"
  12.  
  13. # with the same precision you use
  14. o = Order.new(:price => BigDecimal.new('6.47', 4))
  15. o.to_xml
  16. #=> "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<order>\n <price type=\"decimal\">6.47</price>\n</order>\n"
Add Comment
Please, Sign In to add comment