Skip to content

Instantly share code, notes, and snippets.

@jimmybaker
Created September 6, 2012 19:10
Show Gist options
  • Save jimmybaker/3659591 to your computer and use it in GitHub Desktop.
Save jimmybaker/3659591 to your computer and use it in GitHub Desktop.
Dirt simple shipping matrix
class ShippingMatrix
@matrix = {
(1..10) => 2.50,
(11..20) => 5.00,
(21..30) => 10
}
def self.price_for(quantity)
@matrix.find { |range, price| range.include?(quantity) }[1]
end
end
ShippingMatrix.price_for(15)
=> 5.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment