Class: Factorix::MOD
- Inherits:
-
Data
- Object
- Data
- Factorix::MOD
- Includes:
- Comparable
- Defined in:
- lib/factorix/mod.rb,
lib/factorix/mod.rb
Overview
Represents a local MOD
This class encapsulates a MOD’s name and provides utility methods for MOD identification and comparison.
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The name of the MOD.
Instance Method Summary collapse
-
#<=>(other) ⇒ Integer
Compare this MOD with another MOD by name.
-
#base? ⇒ Boolean
Check if this MOD is the base MOD.
-
#expansion? ⇒ Boolean
Check if this MOD is an expansion MOD.
-
#to_s ⇒ String
Return the name of the MOD.
Instance Attribute Details
#name ⇒ String (readonly)
Returns the name of the MOD.
13 14 15 |
# File 'lib/factorix/mod.rb', line 13 def name @name end |
Instance Method Details
#<=>(other) ⇒ Integer
Note:
Comparison is case-sensitive for MOD names.
Note:
The base MOD (exactly “base”, case-sensitive) always comes before any other MOD.
Compare this MOD with another MOD by name
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/factorix/mod.rb', line 43 def <=>(other) return nil unless other.is_a?(MOD) if base? other.base? ? 0 : -1 elsif other.base? 1 else name <=> other.name end end |
#base? ⇒ Boolean
Note:
The check is case-sensitive, only “base” (not “BASE” or “Base”) is considered the base MOD
Check if this MOD is the base MOD
24 |
# File 'lib/factorix/mod.rb', line 24 def base? = name == "base" |
#expansion? ⇒ Boolean
Note:
The check is case-sensitive
Check if this MOD is an expansion MOD
30 |
# File 'lib/factorix/mod.rb', line 30 def expansion? = EXPANSION_MODS.include?(name) |
#to_s ⇒ String
Return the name of the MOD
35 |
# File 'lib/factorix/mod.rb', line 35 def to_s = name |