Class: Factorix::Dependency::Node

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

Overview

Represents a MOD node in the dependency graph

Each node represents a MOD with its version, installation state, and enabled state. Operations can be planned on nodes (:enable, :disable, :install, :uninstall).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mod:, version:, enabled: false, installed: false, operation: nil) ⇒ Node

Returns a new instance of Node.



24
# File 'lib/factorix/dependency/node.rb', line 24

def initialize(mod:, version:, enabled: false, installed: false, operation: nil) = super

Instance Attribute Details

#enabledBoolean (readonly)

Returns Whether the MOD is enabled.

Returns:

  • (Boolean)

    Whether the MOD is enabled



24
25
26
# File 'lib/factorix/dependency/node.rb', line 24

def enabled
  @enabled
end

#installedBoolean (readonly)

Returns Whether the MOD is installed.

Returns:

  • (Boolean)

    Whether the MOD is installed



24
25
26
# File 'lib/factorix/dependency/node.rb', line 24

def installed
  @installed
end

#modFactorix::MOD (readonly)

Returns The MOD identifier.

Returns:



24
25
26
# File 'lib/factorix/dependency/node.rb', line 24

def mod
  @mod
end

#operationSymbol? (readonly)

Returns Planned operation (:enable, :disable, :install, :uninstall, nil).

Returns:

  • (Symbol, nil)

    Planned operation (:enable, :disable, :install, :uninstall, nil)



24
25
26
# File 'lib/factorix/dependency/node.rb', line 24

def operation
  @operation
end

#versionFactorix::MODVersion (readonly)

Returns The MOD version.

Returns:



24
25
26
# File 'lib/factorix/dependency/node.rb', line 24

def version
  @version
end

Instance Method Details

#enabled?Boolean

Check if the MOD is enabled

Returns:

  • (Boolean)


29
# File 'lib/factorix/dependency/node.rb', line 29

def enabled? = enabled

#inspectString

Detailed inspection string

Returns:

  • (String)


57
# File 'lib/factorix/dependency/node.rb', line 57

def inspect = "#<#{self.class.name} #{self}>"

#installed?Boolean

Check if the MOD is installed

Returns:

  • (Boolean)


34
# File 'lib/factorix/dependency/node.rb', line 34

def installed? = installed

#operation?Boolean

Check if an operation is planned for this node

Returns:

  • (Boolean)


39
# File 'lib/factorix/dependency/node.rb', line 39

def operation? = !operation.nil?

#to_sString

String representation of the node

Returns:

  • (String)


44
45
46
47
48
49
50
51
52
# File 'lib/factorix/dependency/node.rb', line 44

def to_s
  state_flags = []
  state_flags << "enabled" if enabled
  state_flags << "installed" if installed
  state_flags << "op:#{operation}" if operation

  state = state_flags.empty? ? "new" : state_flags.join(", ")
  "#{mod} v#{version} (#{state})"
end