Class: RosettAi::Licensing::Tier
- Inherits:
-
Object
- Object
- RosettAi::Licensing::Tier
- Includes:
- Comparable
- Defined in:
- lib/rosett_ai/licensing/tier.rb
Overview
Represents a license tier with comparable ordering.
Tiers control access to premium content pack downloads — they NEVER restrict software functionality (GPL-3.0 compliance).
Constant Summary collapse
- HIERARCHY =
{ community: 0, supporter: 1, subscriber: 2, enterprise: 3 }.freeze
- NAMES =
HIERARCHY.keys.freeze
Instance Attribute Summary collapse
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #entitled_to?(required) ⇒ Boolean
-
#initialize(name) ⇒ Tier
constructor
A new instance of Tier.
- #to_s ⇒ Object
Constructor Details
#initialize(name) ⇒ Tier
Returns a new instance of Tier.
20 21 22 23 24 25 26 |
# File 'lib/rosett_ai/licensing/tier.rb', line 20 def initialize(name) sym = name.to_s.downcase.to_sym raise RosettAi::LicenseError, "unknown tier: #{name}" unless HIERARCHY.key?(sym) @name = sym @level = HIERARCHY[sym] end |
Instance Attribute Details
#level ⇒ Object (readonly)
Returns the value of attribute level.
18 19 20 |
# File 'lib/rosett_ai/licensing/tier.rb', line 18 def level @level end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
18 19 20 |
# File 'lib/rosett_ai/licensing/tier.rb', line 18 def name @name end |
Instance Method Details
#<=>(other) ⇒ Object
28 29 30 |
# File 'lib/rosett_ai/licensing/tier.rb', line 28 def <=>(other) level <=> other.level end |
#entitled_to?(required) ⇒ Boolean
32 33 34 35 |
# File 'lib/rosett_ai/licensing/tier.rb', line 32 def entitled_to?(required) other = required.is_a?(Tier) ? required : Tier.new(required) self >= other end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/rosett_ai/licensing/tier.rb', line 37 def to_s name.to_s.capitalize end |