Class: Lapidarist::Level
- Inherits:
-
Object
- Object
- Lapidarist::Level
- Includes:
- Comparable
- Defined in:
- lib/lapidarist/level.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(name:, index:) ⇒ Level
constructor
A new instance of Level.
- #to_s ⇒ Object
Constructor Details
#initialize(name:, index:) ⇒ Level
Returns a new instance of Level.
7 8 9 10 |
# File 'lib/lapidarist/level.rb', line 7 def initialize(name:, index:) @name = name @index = index end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
5 6 7 |
# File 'lib/lapidarist/level.rb', line 5 def index @index end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/lapidarist/level.rb', line 5 def name @name end |
Class Method Details
.from(name) ⇒ Object
12 13 14 15 |
# File 'lib/lapidarist/level.rb', line 12 def self.from(name) return unless name Lapidarist::LEVELS.detect { |l| l.name == name.to_sym } end |
Instance Method Details
#<=>(other) ⇒ Object
21 22 23 24 25 |
# File 'lib/lapidarist/level.rb', line 21 def <=>(other) return 1 if index < other.index return 0 if index == other.index return -1 if index > other.index end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/lapidarist/level.rb', line 17 def to_s name.to_s end |