Sha256: 6107e3f6392cb692c5db49090552a68f4a31bc6ec2d8ccee1e112b1342f6cc35
Contents?: true
Size: 773 Bytes
Versions: 1
Compression:
Stored size: 773 Bytes
Contents
module Charger class Price include Virtus.model attribute :ending_quantity, Integer attribute :starting_quantity, Integer, default: 0 attribute :unit_price, Float def between_quantities? amount if ending_quantity starting_quantity <= amount && ending_quantity >= amount else starting_quantity <= amount end end def remaining_quantity amount if ending_quantity amount - ending_quantity else amount end end def total amount return 0.0 if amount < starting_quantity if ending_quantity && amount > ending_quantity ending_quantity * unit_price else (amount - (starting_quantity-1)) * unit_price end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
charger-0.2.0 | lib/charger/price.rb |