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 =
Returns Ordered tier hierarchy from lowest to highest.
{ community: 0, supporter: 1, subscriber: 2, enterprise: 3 }.freeze
- NAMES =
Returns Human-readable names for each tier.
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) ⇒ Integer
Compare tier levels for sorting.
- #entitled_to?(required) ⇒ Boolean
-
#initialize(name) ⇒ Tier
constructor
A new instance of Tier.
-
#to_s ⇒ String
Return the human-readable tier name.
Constructor Details
#initialize(name) ⇒ Tier
Returns a new instance of Tier.
23 24 25 26 27 28 29 |
# File 'lib/rosett_ai/licensing/tier.rb', line 23 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.
21 22 23 |
# File 'lib/rosett_ai/licensing/tier.rb', line 21 def level @level end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
21 22 23 |
# File 'lib/rosett_ai/licensing/tier.rb', line 21 def name @name end |
Instance Method Details
#<=>(other) ⇒ Integer
Compare tier levels for sorting.
35 36 37 |
# File 'lib/rosett_ai/licensing/tier.rb', line 35 def <=>(other) level <=> other.level end |
#entitled_to?(required) ⇒ Boolean
39 40 41 42 |
# File 'lib/rosett_ai/licensing/tier.rb', line 39 def entitled_to?(required) other = required.is_a?(Tier) ? required : Tier.new(required) self >= other end |
#to_s ⇒ String
Return the human-readable tier name.
46 47 48 |
# File 'lib/rosett_ai/licensing/tier.rb', line 46 def to_s name.to_s.capitalize end |