Skip to content

Commit

Permalink
1.8.7 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Siegel committed Nov 29, 2010
1 parent ca39f62 commit f4be1ca
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/foto_verite/package.rb
Expand Up @@ -45,18 +45,18 @@ def cylinder?

def ounces(options={})
case options[:type]
when *[nil,:actual]; @ounces ||= grams(options) * OUNCES_IN_A_GRAM
when *[:volumetric,:dimensional]; @volumetric_ounces ||= grams(options) * OUNCES_IN_A_GRAM
when :billable; @billable_ounces ||= [ounces,ounces(:type => :volumetric)].max
when *[nil,:actual] then @ounces ||= grams(options) * OUNCES_IN_A_GRAM
when *[:volumetric,:dimensional] then @volumetric_ounces ||= grams(options) * OUNCES_IN_A_GRAM
when :billable then @billable_ounces ||= [ounces,ounces(:type => :volumetric)].max
end
end
alias_method :oz, :ounces

def grams(options={})
case options[:type]
when *[nil,:actual]; @grams ||= ounces(options) * GRAMS_IN_AN_OUNCE
when *[:volumetric,:dimensional]; @volumetric_grams ||= centimetres(:box_volume) / 6.0
when :billable; [grams,grams(:type => :volumetric)].max
when *[nil,:actual] then @grams ||= ounces(options) * GRAMS_IN_AN_OUNCE
when *[:volumetric,:dimensional] then @volumetric_grams ||= centimetres(:box_volume) / 6.0
when :billable then [grams,grams(:type => :volumetric)].max
end
end
alias_method :g, :grams
Expand Down Expand Up @@ -106,14 +106,14 @@ def self.cents_from(money)

def measure(measurement, ary)
case measurement
when Fixnum; ary[measurement]
when *[:x,:max,:length,:long]; ary[2]
when *[:y,:mid,:width,:wide]; ary[1]
when *[:z,:min,:height,:depth,:high,:deep]; ary[0]
when Fixnum then ary[measurement]
when *[:x,:max,:length,:long] then ary[2]
when *[:y,:mid,:width,:wide] then ary[1]
when *[:z,:min,:height,:depth,:high,:deep] then ary[0]
when *[:girth,:around,:circumference]
self.cylinder? ? (Math::PI * (ary[0] + ary[1]) / 2) : (2 * ary[0]) + (2 * ary[1])
when :volume; self.cylinder? ? (Math::PI * (ary[0] + ary[1]) / 4)**2 * ary[2] : measure(:box_volume,ary)
when :box_volume; ary[0] * ary[1] * ary[2]
when :volume then self.cylinder? ? (Math::PI * (ary[0] + ary[1]) / 4)**2 * ary[2] : measure(:box_volume,ary)
when :box_volume then ary[0] * ary[1] * ary[2]
end
end

Expand Down

0 comments on commit f4be1ca

Please sign in to comment.