Class: LabelMe::Order::LineItem

Inherits:
Object
  • Object
show all
Defined in:
lib/label_me/order/line_item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(row) ⇒ LineItem

Returns a new instance of LineItem.



4
5
6
7
8
9
# File 'lib/label_me/order/line_item.rb', line 4

def initialize(row)
  @number     = row.line_item_id.to_i
  @quantity   = row.line_item_quantity.to_i
  @unit_price = row.line_item_unit_price.to_i
  @code       = row.line_item_code
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



14
15
16
# File 'lib/label_me/order/line_item.rb', line 14

def code
  @code
end

#numberObject

Returns the value of attribute number.



11
12
13
# File 'lib/label_me/order/line_item.rb', line 11

def number
  @number
end

#quantityObject

Returns the value of attribute quantity.



12
13
14
# File 'lib/label_me/order/line_item.rb', line 12

def quantity
  @quantity
end

#unit_priceObject

Returns the value of attribute unit_price.



13
14
15
# File 'lib/label_me/order/line_item.rb', line 13

def unit_price
  @unit_price
end

Instance Method Details

#===(other) ⇒ Object



25
26
27
# File 'lib/label_me/order/line_item.rb', line 25

def ===(other)
  self.number == other.number
end

#to_hashObject



16
17
18
19
20
21
22
23
# File 'lib/label_me/order/line_item.rb', line 16

def to_hash
  {
    number:     number,
    quantity:   quantity,
    unit_price: unit_price,
    code:       code
  }
end