Class: Legion::Extensions::Agentic::Attention::Lighthouse::Helpers::Fog

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/agentic/attention/lighthouse/helpers/fog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#densityObject

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

#domainObject (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

#extentObject (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_typeObject (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_atObject (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

#idObject (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

Returns:

  • (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

Returns:

  • (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_hObject



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_labelObject



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