Class: SalesTax::LineItem::Base

Inherits:
Object
  • Object
show all
Includes:
Accountable
Defined in:
lib/sales_tax/line_item/base.rb

Direct Known Subclasses

Book, Food, Medicine

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Base

Returns a new instance of Base.



12
13
14
15
16
# File 'lib/sales_tax/line_item/base.rb', line 12

def initialize(args = {})
  @quantity_str = args[:quantity] || ''
  @description = args[:description]
  @unit_price_str = args[:unit_price] || ''
end

Class Method Details

.augment(attributes) ⇒ Object



8
9
10
# File 'lib/sales_tax/line_item/base.rb', line 8

def self.augment(attributes)
  new(attributes).to_hash if attributes[:description] =~ description_matcher
end

Instance Method Details

#to_hashObject



18
19
20
21
22
23
24
25
26
# File 'lib/sales_tax/line_item/base.rb', line 18

def to_hash
  accountable_hash.merge(
    {
      quantity: quantity_str,
      description: description,
      unit_price: unit_price_str
    }
  )
end