Class: LabelMe::Order
- Inherits:
-
Object
- Object
- LabelMe::Order
- Defined in:
- lib/label_me/order.rb,
lib/label_me/order/customer.rb,
lib/label_me/order/line_item.rb,
lib/label_me/order/recipient.rb
Defined Under Namespace
Classes: Customer, LineItem, Recipient
Instance Attribute Summary collapse
-
#customer ⇒ Object
Returns the value of attribute customer.
-
#message_card_charge ⇒ Object
Returns the value of attribute message_card_charge.
-
#number ⇒ Object
Returns the value of attribute number.
-
#order_date ⇒ Object
Returns the value of attribute order_date.
-
#recipients ⇒ Object
Returns the value of attribute recipients.
-
#shipping_charge ⇒ Object
Returns the value of attribute shipping_charge.
Instance Method Summary collapse
- #===(other) ⇒ Object
-
#initialize(row) ⇒ Order
constructor
A new instance of Order.
- #paid? ⇒ Boolean
- #to_hash ⇒ Object
Constructor Details
#initialize(row) ⇒ Order
Returns a new instance of Order.
6 7 8 9 10 11 12 13 14 |
# File 'lib/label_me/order.rb', line 6 def initialize(row) @number = row.order_id.to_i @order_date = row.order_date @paid = row.paid? @shipping_charge = row.total_shipping_charge @message_card_charge = row. @customer = LabelMe::Order::Customer.new(row) @recipients = [LabelMe::Order::Recipient.new(row)] end |
Instance Attribute Details
#customer ⇒ Object
Returns the value of attribute customer.
20 21 22 |
# File 'lib/label_me/order.rb', line 20 def customer @customer end |
#message_card_charge ⇒ Object
Returns the value of attribute message_card_charge.
19 20 21 |
# File 'lib/label_me/order.rb', line 19 def @message_card_charge end |
#number ⇒ Object
Returns the value of attribute number.
16 17 18 |
# File 'lib/label_me/order.rb', line 16 def number @number end |
#order_date ⇒ Object
Returns the value of attribute order_date.
17 18 19 |
# File 'lib/label_me/order.rb', line 17 def order_date @order_date end |
#recipients ⇒ Object
Returns the value of attribute recipients.
21 22 23 |
# File 'lib/label_me/order.rb', line 21 def recipients @recipients end |
#shipping_charge ⇒ Object
Returns the value of attribute shipping_charge.
18 19 20 |
# File 'lib/label_me/order.rb', line 18 def shipping_charge @shipping_charge end |
Instance Method Details
#===(other) ⇒ Object
39 40 41 |
# File 'lib/label_me/order.rb', line 39 def ===(other) self.number == other.number end |
#paid? ⇒ Boolean
23 24 25 |
# File 'lib/label_me/order.rb', line 23 def paid? @paid end |
#to_hash ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/label_me/order.rb', line 27 def to_hash { number: number, order_date: order_date, paid?: paid?, shipping_charge: shipping_charge, message_card_charge: , customer_attributes: customer.to_hash, recipients_attributes: recipients.map(&:to_hash), } end |