shopicruit 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/shopicruit.rb +2 -3
- data/lib/shopicruit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3b6ef33a5bef15ea56d6413faee67cfae5ce363
|
4
|
+
data.tar.gz: 933e9f87c644259e87739f3d4fa1fc91e699f810
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cebc68a6df88f7049c7383aa42d67c3194e49e3af920a9a03a608448bbc2571fe66ae98faa456af3136c6475b52d64c1d57d559fc9de3185981226bec98c3703
|
7
|
+
data.tar.gz: 25c0e7d20d755cad091a1b5aa3f34ad94a97f14458a8ca05bf1f27478772170d581bf11139039865090184e29153617bf475f623d68a4af375f3bda63cfddbff
|
data/README.md
CHANGED
@@ -20,8 +20,8 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
* maxAmount method calculates the maximum amount of items that could be purchased within the weight limit
|
24
|
-
|
23
|
+
* maxAmount method calculates the maximum amount of items that could be purchased within the weight limit.
|
24
|
+
It takes three arguments:
|
25
25
|
+ First argument takes in the maximum weight in kg.
|
26
26
|
+ Second argument takes in the desired return type. ('cost', 'weight', or 'products')
|
27
27
|
+ Third arguments takes in a list of types of products. ('Keyboard', 'Computer', 'Clock', 'Car', 'Bottle', 'Wallet', 'Knife', 'Lamp', 'Table', 'Chair', 'Hat', 'Shoes', 'Plate', 'Gloves', 'Bag', 'Coat', 'Pants')
|
data/lib/shopicruit.rb
CHANGED
@@ -28,7 +28,7 @@ class Shopicruit
|
|
28
28
|
if (item_list.include? item["product_type"])
|
29
29
|
item["variants"].each do |var|
|
30
30
|
title = item["title"] + " (" + var["title"] + ")"
|
31
|
-
desiredProductList[title] = { "weight" => var["grams"], "price" => var["price"].to_f }
|
31
|
+
desiredProductList[title] = { "weight" => var["grams"]/1000.0, "price" => var["price"].to_f }
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -37,7 +37,6 @@ class Shopicruit
|
|
37
37
|
|
38
38
|
|
39
39
|
def self.calculate(products, maxWeight)
|
40
|
-
maxWeight *= 1000
|
41
40
|
totalWeight = 0.0
|
42
41
|
totalPrice = 0.0
|
43
42
|
cart = []
|
@@ -49,7 +48,7 @@ class Shopicruit
|
|
49
48
|
cart.push product_name
|
50
49
|
end
|
51
50
|
end
|
52
|
-
return {"cost" => "$" + totalPrice
|
51
|
+
return {"cost" => ("$" + '%.2f' % totalPrice), "weight" => ('%.2f' % totalWeight + "kg"), "products" => cart}
|
53
52
|
end
|
54
53
|
|
55
54
|
private_class_method :calculate, :get_product_list
|
data/lib/shopicruit/version.rb
CHANGED