superfeature 0.1.3 → 0.1.5

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: 8fc5708efe44ee4472cc5f8ff78f3e7351e5f605e50828571db62f7919da128c
4
+ data.tar.gz: d217d3329d95a792f988640e0512b5a23cc8b77f62fbd03af5e26d2e87096106
5
5
  SHA512:
6
- metadata.gz: bfa175930e17f348f4a2766601b45515b7f8c242526dd07ce37229c8bf4b06a8bdc031cccf0e99a7df1720d59c6c70a520412c93c62a1b2dd1c437a81443973f
7
- data.tar.gz: 99fce65c67de1d832c0298bb6dfe0c4e75b07131d9c8e2ddaeb11451d573d45da2e46cd74a54e362f9a5f8d5b22f5c4814c4e94aa9e93bb130b69daa2b9cfd27
6
+ metadata.gz: 316e53bda0b475e1268c8272ef1f493f377034c2ef7020af71cb261b6c60548fb6d0a3f090001d9f591e77aa3d4c54845a76e23b851698537b7df1ffdf21bf71
7
+ data.tar.gz: 7182e2ac76b85ecac8b3c49f812f53a2a1e936bdb61a4b6c2fe60d63e513e49a45004c041f12a215c1d920e93392653ac74f927b846719efdfa6a54e492e694b
data/README.md CHANGED
@@ -301,6 +301,10 @@ module Plans
301
301
 
302
302
  # Override features from Base to enable them
303
303
  # def priority_support = super.enable
304
+ #
305
+ # Conditionally enable/disable based on a boolean:
306
+ # def dark_mode = super.enable(user.premium?)
307
+ # def legacy_feature = super.disable(user.migrated?)
304
308
 
305
309
  # Link to adjacent plans for navigation
306
310
  # def next = plan NextPlan
@@ -331,6 +335,7 @@ price.discount_percent(0.25) # => $75.00 (25% off)
331
335
  price.discount("25%") # => $75.00 (parses string)
332
336
  price.discount("$20") # => $80.00 (parses string)
333
337
  price.discount(20) # => $80.00 (numeric = dollars)
338
+ price.to(80) # => $80.00 (set target price directly)
334
339
 
335
340
  # Chain discounts
336
341
  price = Superfeature::Price.new(100.00)
@@ -12,14 +12,13 @@ module Superfeature
12
12
  @limit = limit
13
13
  end
14
14
 
15
- def enable
16
- @limit = Limit::Boolean.new(enabled: true)
15
+ def enable(value = true)
16
+ @limit = Limit::Boolean.new(enabled: value)
17
17
  self
18
18
  end
19
19
 
20
- def disable
21
- @limit = Limit::Boolean.new(enabled: false)
22
- self
20
+ def disable(value = true)
21
+ enable(!value)
23
22
  end
24
23
 
25
24
  def boolean?
@@ -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.5"
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.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Gessler