Class: Legion::Extensions::Agentic::Attention::Lighthouse::Helpers::Fog
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Attention::Lighthouse::Helpers::Fog
- Defined in:
- lib/legion/extensions/agentic/attention/lighthouse/helpers/fog.rb
Instance Attribute Summary collapse
-
#density ⇒ Object
Returns the value of attribute density.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#extent ⇒ Object
readonly
Returns the value of attribute extent.
-
#fog_type ⇒ Object
readonly
Returns the value of attribute fog_type.
-
#formed_at ⇒ Object
readonly
Returns the value of attribute formed_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #clearing? ⇒ Boolean
- #disperse!(rate: Constants::FOG_DENSITY_RATE) ⇒ Object
- #impenetrable? ⇒ Boolean
-
#initialize(fog_type:, domain:, density: nil, extent: nil) ⇒ Fog
constructor
A new instance of Fog.
- #thicken!(rate: Constants::FOG_DENSITY_RATE) ⇒ Object
- #to_h ⇒ Object
- #visibility_label ⇒ Object
Constructor Details
#initialize(fog_type:, domain:, density: nil, extent: nil) ⇒ Fog
Returns a new instance of Fog.
13 14 15 16 17 18 19 20 21 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/fog.rb', line 13 def initialize(fog_type:, domain:, density: nil, extent: nil) validate_fog_type!(fog_type) @id = SecureRandom.uuid @fog_type = fog_type.to_sym @domain = domain.to_s @density = (density || 0.5).to_f.clamp(0.0, 1.0).round(10) @extent = (extent || 1.0).to_f.clamp(0.0, 1.0).round(10) @formed_at = Time.now.utc end |
Instance Attribute Details
#density ⇒ Object
Returns the value of attribute density.
11 12 13 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/fog.rb', line 11 def density @density end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
10 11 12 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/fog.rb', line 10 def domain @domain end |
#extent ⇒ Object (readonly)
Returns the value of attribute extent.
10 11 12 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/fog.rb', line 10 def extent @extent end |
#fog_type ⇒ Object (readonly)
Returns the value of attribute fog_type.
10 11 12 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/fog.rb', line 10 def fog_type @fog_type end |
#formed_at ⇒ Object (readonly)
Returns the value of attribute formed_at.
10 11 12 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/fog.rb', line 10 def formed_at @formed_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/fog.rb', line 10 def id @id end |
Instance Method Details
#clearing? ⇒ Boolean
37 38 39 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/fog.rb', line 37 def clearing? @density < 0.2 end |
#disperse!(rate: Constants::FOG_DENSITY_RATE) ⇒ Object
28 29 30 31 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/fog.rb', line 28 def disperse!(rate: Constants::FOG_DENSITY_RATE) @density = (@density - rate).clamp(0.0, 1.0).round(10) self end |
#impenetrable? ⇒ Boolean
33 34 35 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/fog.rb', line 33 def impenetrable? @density >= 1.0 end |
#thicken!(rate: Constants::FOG_DENSITY_RATE) ⇒ Object
23 24 25 26 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/fog.rb', line 23 def thicken!(rate: Constants::FOG_DENSITY_RATE) @density = (@density + rate).clamp(0.0, 1.0).round(10) self end |
#to_h ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/fog.rb', line 45 def to_h { id: @id, fog_type: @fog_type, domain: @domain, density: @density, extent: @extent, visibility_label: visibility_label, impenetrable: impenetrable?, clearing: clearing?, formed_at: @formed_at } end |
#visibility_label ⇒ Object
41 42 43 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/fog.rb', line 41 def visibility_label Constants.label_for(Constants::VISIBILITY_LABELS, @density) end |