Class: Legion::Extensions::Agentic::Homeostasis::Weathering::Helpers::Stressor
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Homeostasis::Weathering::Helpers::Stressor
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/homeostasis/weathering/helpers/stressor.rb
Constant Summary
Constants included from Constants
Constants::BREAKDOWN_INTEGRITY, Constants::CRITICAL_INTEGRITY, Constants::DEFAULT_INTEGRITY, Constants::INTEGRITY_LABELS, Constants::MAX_EVENTS, Constants::MAX_STRESSORS, Constants::RECOVERY_RATE, Constants::STRESSOR_TYPES, Constants::TEMPERING_RATE, Constants::TEMPERING_THRESHOLD, Constants::WEAR_RATE, Constants::WEATHERING_LABELS
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#intensity ⇒ Object
readonly
Returns the value of attribute intensity.
-
#recorded_at ⇒ Object
readonly
Returns the value of attribute recorded_at.
-
#stressor_type ⇒ Object
readonly
Returns the value of attribute stressor_type.
Instance Method Summary collapse
- #cumulative_impact ⇒ Object
-
#initialize(description:, stressor_type:, intensity:, duration:, domain: nil) ⇒ Stressor
constructor
A new instance of Stressor.
- #manageable? ⇒ Boolean
- #overwhelming? ⇒ Boolean
- #to_h ⇒ Object
Methods included from Constants
integrity_label, weathering_label
Constructor Details
#initialize(description:, stressor_type:, intensity:, duration:, domain: nil) ⇒ Stressor
Returns a new instance of Stressor.
16 17 18 19 20 21 22 23 24 |
# File 'lib/legion/extensions/agentic/homeostasis/weathering/helpers/stressor.rb', line 16 def initialize(description:, stressor_type:, intensity:, duration:, domain: nil) @id = SecureRandom.uuid @description = description @stressor_type = validate_type(stressor_type) @intensity = intensity.clamp(0.0, 1.0) @duration = [duration.to_f, 0.0].max @domain = domain @recorded_at = Time.now.utc end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
14 15 16 |
# File 'lib/legion/extensions/agentic/homeostasis/weathering/helpers/stressor.rb', line 14 def description @description end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
14 15 16 |
# File 'lib/legion/extensions/agentic/homeostasis/weathering/helpers/stressor.rb', line 14 def domain @domain end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
14 15 16 |
# File 'lib/legion/extensions/agentic/homeostasis/weathering/helpers/stressor.rb', line 14 def duration @duration end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/homeostasis/weathering/helpers/stressor.rb', line 14 def id @id end |
#intensity ⇒ Object (readonly)
Returns the value of attribute intensity.
14 15 16 |
# File 'lib/legion/extensions/agentic/homeostasis/weathering/helpers/stressor.rb', line 14 def intensity @intensity end |
#recorded_at ⇒ Object (readonly)
Returns the value of attribute recorded_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/homeostasis/weathering/helpers/stressor.rb', line 14 def recorded_at @recorded_at end |
#stressor_type ⇒ Object (readonly)
Returns the value of attribute stressor_type.
14 15 16 |
# File 'lib/legion/extensions/agentic/homeostasis/weathering/helpers/stressor.rb', line 14 def stressor_type @stressor_type end |
Instance Method Details
#cumulative_impact ⇒ Object
26 27 28 |
# File 'lib/legion/extensions/agentic/homeostasis/weathering/helpers/stressor.rb', line 26 def cumulative_impact (intensity * (duration / 3600.0)).clamp(0.0, 1.0).round(10) end |
#manageable? ⇒ Boolean
30 31 32 |
# File 'lib/legion/extensions/agentic/homeostasis/weathering/helpers/stressor.rb', line 30 def manageable? intensity <= Constants::TEMPERING_THRESHOLD end |
#overwhelming? ⇒ Boolean
34 35 36 |
# File 'lib/legion/extensions/agentic/homeostasis/weathering/helpers/stressor.rb', line 34 def overwhelming? intensity >= 0.8 end |
#to_h ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/legion/extensions/agentic/homeostasis/weathering/helpers/stressor.rb', line 38 def to_h { id: id, description: description, stressor_type: stressor_type, intensity: intensity, duration: duration, domain: domain, cumulative_impact: cumulative_impact, manageable: manageable?, overwhelming: overwhelming?, recorded_at: recorded_at.iso8601 } end |