Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. # File: yaml-to-order.rb
  2. #
  3. require 'Date'
  4. require 'yaml'
  5.  
  6. class Customer
  7. attr_accessor :name,
  8. :address
  9.  
  10. def initialize(name, address)
  11. @name = name
  12. @address = address
  13. end
  14. end
  15.  
  16. class OrderItem
  17. attr_accessor :id,
  18. :item,
  19. :item_type,
  20. :price,
  21. :currency
  22.  
  23. def initialize(id, item, item_type, price, currency)
  24. @id = id
  25. @item = item
  26. @item_type = item_type
  27. @price = price
  28. @currency = currency
  29. end
  30. end
  31.  
  32. class Order
  33. attr_accessor :order_number,
  34. :order_date,
  35. :customer,
  36. :order_details
  37. end
  38.  
  39. order = YAML.load_file('order.yml')
  40. puts order.inspect
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement