Class: Factorix::MOD

Inherits:
Data
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#nameString (readonly)

Returns the name of the MOD.

Returns:

  • (String)

    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

Parameters:

  • other (MOD)

    the other MOD

Returns:

  • (Integer)

    -1 if this MOD precedes the other, 0 if they are equal, 1 if this MOD follows the other



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

Returns:

  • (Boolean)

    true 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

Returns:

  • (Boolean)

    true if this MOD is an expansion MOD (space-age, quality, or elevated-rails)



30
# File 'lib/factorix/mod.rb', line 30

def expansion? = EXPANSION_MODS.include?(name)

#to_sString

Return the name of the MOD

Returns:

  • (String)

    the name of the MOD



35
# File 'lib/factorix/mod.rb', line 35

def to_s = name