Class: Shopicruit
- Inherits:
-
Object
- Object
- Shopicruit
- Defined in:
- lib/shopicruit.rb,
lib/shopicruit/version.rb
Constant Summary collapse
- VERSION =
"0.0.4"
Class Method Summary collapse
- .leastCost(maxWeight, return_type, item_list) ⇒ Object
- .maxAmount(maxWeight, return_type, item_list) ⇒ Object
Class Method Details
.leastCost(maxWeight, return_type, item_list) ⇒ Object
13 14 15 16 17 |
# File 'lib/shopicruit.rb', line 13 def self.leastCost(maxWeight, return_type, item_list) products = get_product_list(item_list).sort_by{ |key, value| value["price"] / value["weight"] }.to_h result = calculate(products, maxWeight) return result[return_type] end |
.maxAmount(maxWeight, return_type, item_list) ⇒ Object
6 7 8 9 10 |
# File 'lib/shopicruit.rb', line 6 def self.maxAmount(maxWeight, return_type, item_list) products = get_product_list(item_list).sort_by{ |key, value| value["weight"] }.to_h result = calculate(products, maxWeight) return result[return_type] end |