shopicruit 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4983ee73be467a49610ab092a3a026a38b146bbe
4
- data.tar.gz: 187f001d1f6c45130300e2d6476cb50d20c172b0
3
+ metadata.gz: b3b6ef33a5bef15ea56d6413faee67cfae5ce363
4
+ data.tar.gz: 933e9f87c644259e87739f3d4fa1fc91e699f810
5
5
  SHA512:
6
- metadata.gz: 71b0f19172d2c39442b005627008f875bfbeae60544bcc691931e51fa12377732a6ea87f419d4a69bd63714f573bf7911cff6be08044ef731a2c255acf06c918
7
- data.tar.gz: adbcf173f0beaf6d6115bf8525904b39c3373ae229e38f9bfb86b686cb132d2631330b086db4400ef5d4ca38b885fd96e3c1d61fe39bf24bbbc52001b737833f
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.\s\s
24
- It takes three arguments:
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')
@@ -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.to_s, "weight" => (totalWeight/1000).to_s+"kg", "products" => cart}
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
@@ -1,3 +1,3 @@
1
1
  class Shopicruit
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopicruit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lisa Weng