Class: Factorix::MODState

Inherits:
Data
  • Object
show all
Defined in:
lib/factorix/mod_state.rb,
lib/factorix/mod_state.rb

Overview

Represents the state of a MOD in a MOD list

This class encapsulates the enabled/disabled state and version information for a MOD as it appears in the mod-list.json file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(enabled:, version: nil) ⇒ void

Initialize a new MODState

Examples:

Creating a MODState

state = Factorix::MODState[enabled: true]
version = Factorix::MODVersion.from_string("1.2.3")
state = Factorix::MODState[enabled: false, version: version]

Parameters:

  • enabled (Boolean)

    whether the MOD is enabled

  • version (Factorix::MODVersion, nil) (defaults to: nil)

    the version of the MOD (optional)



21
# File 'lib/factorix/mod_state.rb', line 21

def initialize(enabled:, version: nil) = super

Instance Attribute Details

#enabledBoolean (readonly)

Returns whether the MOD is enabled.

Returns:

  • (Boolean)

    whether the MOD is enabled



23
24
25
# File 'lib/factorix/mod_state.rb', line 23

def enabled
  @enabled
end

#versionFactorix::MODVersion? (readonly)

Returns the version of the MOD, or nil if the version is not specified.

Returns:



26
27
28
# File 'lib/factorix/mod_state.rb', line 26

def version
  @version
end

Instance Method Details

#enabled?Boolean

Check if the MOD is enabled

Returns:

  • (Boolean)

    true if the MOD is enabled, false otherwise



32
# File 'lib/factorix/mod_state.rb', line 32

def enabled? = enabled