Class: Factorix::Dependency::Entry
- Inherits:
-
Data
- Object
- Data
- Factorix::Dependency::Entry
- Defined in:
- lib/factorix/dependency/entry.rb,
lib/factorix/dependency/entry.rb
Overview
Represents a single MOD dependency
This class encapsulates a MOD dependency with its type (required, optional, etc.) and optional version requirement.
Constant Summary collapse
- REQUIRED =
Dependency type constants
:required- OPTIONAL =
:optional- HIDDEN_OPTIONAL =
:hidden- INCOMPATIBLE =
:incompatible- LOAD_NEUTRAL =
:load_neutral
Instance Attribute Summary collapse
-
#mod ⇒ MOD
readonly
The dependent MOD.
-
#type ⇒ Symbol
readonly
Type of dependency (:required, :optional, :hidden, :incompatible, :load_neutral).
-
#version_requirement ⇒ MODVersionRequirement?
readonly
Version requirement (nil if no requirement).
Instance Method Summary collapse
-
#incompatible? ⇒ Boolean
Check if this is an incompatible (conflicting) dependency.
-
#initialize(mod:, type:, version_requirement: nil) ⇒ Entry
constructor
Create a new Entry.
-
#load_neutral? ⇒ Boolean
Check if this dependency does not affect load order.
-
#optional? ⇒ Boolean
Check if this is an optional dependency (including hidden optional).
-
#required? ⇒ Boolean
Check if this is a required dependency.
-
#satisfied_by?(version) ⇒ Boolean
Check if a given version satisfies this dependency’s version requirement.
-
#to_s ⇒ String
Return string representation of the dependency.
Constructor Details
#initialize(mod:, type:, version_requirement: nil) ⇒ Entry
Create a new Entry
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/factorix/dependency/entry.rb', line 58 def initialize(mod:, type:, version_requirement: nil) unless mod.is_a?(MOD) raise ArgumentError, "mod must be a MOD instance, got #{mod.class}" end unless VALID_TYPES.include?(type) raise ArgumentError, "Invalid dependency type: #{type}. Must be one of: #{VALID_TYPES.join(", ")}" end if version_requirement && !version_requirement.is_a?(MODVersionRequirement) raise ArgumentError, "version_requirement must be a MODVersionRequirement or nil, got #{version_requirement.class}" end super end |
Instance Attribute Details
#mod ⇒ MOD (readonly)
Returns The dependent MOD.
6 7 8 |
# File 'lib/factorix/dependency/entry.rb', line 6 def mod @mod end |
#type ⇒ Symbol (readonly)
Returns Type of dependency (:required, :optional, :hidden, :incompatible, :load_neutral).
6 7 8 |
# File 'lib/factorix/dependency/entry.rb', line 6 def type @type end |
#version_requirement ⇒ MODVersionRequirement? (readonly)
Returns Version requirement (nil if no requirement).
6 7 8 |
# File 'lib/factorix/dependency/entry.rb', line 6 def version_requirement @version_requirement end |
Instance Method Details
#incompatible? ⇒ Boolean
Check if this is an incompatible (conflicting) dependency
87 |
# File 'lib/factorix/dependency/entry.rb', line 87 def incompatible? = type == INCOMPATIBLE |
#load_neutral? ⇒ Boolean
Check if this dependency does not affect load order
92 |
# File 'lib/factorix/dependency/entry.rb', line 92 def load_neutral? = type == LOAD_NEUTRAL |
#optional? ⇒ Boolean
Check if this is an optional dependency (including hidden optional)
82 |
# File 'lib/factorix/dependency/entry.rb', line 82 def optional? = type == OPTIONAL || type == HIDDEN_OPTIONAL |
#required? ⇒ Boolean
Check if this is a required dependency
77 |
# File 'lib/factorix/dependency/entry.rb', line 77 def required? = type == REQUIRED |
#satisfied_by?(version) ⇒ Boolean
Check if a given version satisfies this dependency’s version requirement
98 99 100 101 102 |
# File 'lib/factorix/dependency/entry.rb', line 98 def satisfied_by?(version) return true unless version_requirement version_requirement.satisfied_by?(version) end |
#to_s ⇒ String
Return string representation of the dependency
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/factorix/dependency/entry.rb', line 107 def to_s result = case type when REQUIRED then "" when OPTIONAL then "? " when HIDDEN_OPTIONAL then "(?) " when INCOMPATIBLE then "! " when LOAD_NEUTRAL then "~ " else raise ArgumentError, "Unexpected dependency type: #{type}" end result += mod.name result += " #{version_requirement}" if version_requirement result end |