superfeature 0.1.3 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea2cc79603e2a605076a000f1c99224a460e812ca128b1685c9b2ccf84189de9
4
- data.tar.gz: b7c1cc123dd6fadaefbb64b50a0eb2191ce0bab4ffe89aa07ed9e74d4a008776
3
+ metadata.gz: b1cb9113e0c87858b70dfd215f524b9359baf10cf69d51fbcadf5e80010e3929
4
+ data.tar.gz: 0c1b5ad5c8068a211300431b3e881fd164ef04dedc54ba9da4c263108145cdfe
5
5
  SHA512:
6
- metadata.gz: bfa175930e17f348f4a2766601b45515b7f8c242526dd07ce37229c8bf4b06a8bdc031cccf0e99a7df1720d59c6c70a520412c93c62a1b2dd1c437a81443973f
7
- data.tar.gz: 99fce65c67de1d832c0298bb6dfe0c4e75b07131d9c8e2ddaeb11451d573d45da2e46cd74a54e362f9a5f8d5b22f5c4814c4e94aa9e93bb130b69daa2b9cfd27
6
+ metadata.gz: da1075eb85dfb9fa91f73ba8fc07c095997ddfa762599da8484ba546e07b64973c33dabe911151f86a5b10513cd52390828154dfde631bc2fff99b82945674eb
7
+ data.tar.gz: fa0bea7dda490f95f9be6fa2736858b526ba2247254d74e22b9f8986e9e42b78cb7d1de534833076045ae2dc3f72b0a92d0dd489522177c0a1c32838ac80cd4f
data/README.md CHANGED
@@ -331,6 +331,7 @@ price.discount_percent(0.25) # => $75.00 (25% off)
331
331
  price.discount("25%") # => $75.00 (parses string)
332
332
  price.discount("$20") # => $80.00 (parses string)
333
333
  price.discount(20) # => $80.00 (numeric = dollars)
334
+ price.to(80) # => $80.00 (set target price directly)
334
335
 
335
336
  # Chain discounts
336
337
  price = Superfeature::Price.new(100.00)
@@ -45,6 +45,12 @@ module Superfeature
45
45
  Price.new(new_amount, original: self, amount_precision: @amount_precision, percent_precision: @percent_precision)
46
46
  end
47
47
 
48
+ # Set the price to a specific amount (calculates discount from current amount)
49
+ # Price(300).to(200) is equivalent to Price(300).discount_fixed(100)
50
+ def to(new_amount)
51
+ discount_fixed([@amount - new_amount.to_f, 0].max)
52
+ end
53
+
48
54
  # Apply a percentage discount (decimal, e.g., 0.25 for 25%)
49
55
  def discount_percent(percent)
50
56
  discount_amount = @amount * percent.to_f
@@ -1,3 +1,3 @@
1
1
  module Superfeature
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: superfeature
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Gessler