class Jamef::Cubage

Attributes

items[RW]

Public Class Methods

new(items) click to toggle source
# File lib/jamef/cubage.rb, line 6
def initialize(items)
  @items = items.kind_of?(Array) ? items : [items]
end

Public Instance Methods

price() click to toggle source
# File lib/jamef/cubage.rb, line 18
def price
  Elegible.new('+', price_sum)
end
to_s() click to toggle source
# File lib/jamef/cubage.rb, line 14
def to_s
  Elegible.new('+', cubage_sum).to_s
end
total() click to toggle source
# File lib/jamef/cubage.rb, line 10
def total
  Elegible.new('+', cubage_sum).total 
end
weight() click to toggle source
# File lib/jamef/cubage.rb, line 22
def weight
  Elegible.new('+', weight_sum)
end

Private Instance Methods

array_sum(variable) click to toggle source
# File lib/jamef/cubage.rb, line 40
def array_sum(variable)
  sum = []
  self.items.each{|item| sum << item.send(variable)}

  sum
end
cubage_sum() click to toggle source
# File lib/jamef/cubage.rb, line 28
def cubage_sum
  array_sum(:cubage)
end
price_sum() click to toggle source
# File lib/jamef/cubage.rb, line 32
def price_sum
  array_sum(:price)
end
weight_sum() click to toggle source
# File lib/jamef/cubage.rb, line 36
def weight_sum
  array_sum(:weight)
end