Class: Legion::Extensions::Agentic::Attention::Lighthouse::Helpers::Beacon
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Attention::Lighthouse::Helpers::Beacon
- Defined in:
- lib/legion/extensions/agentic/attention/lighthouse/helpers/beacon.rb
Instance Attribute Summary collapse
-
#beacon_type ⇒ Object
readonly
Returns the value of attribute beacon_type.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#lit_at ⇒ Object
readonly
Returns the value of attribute lit_at.
-
#luminosity ⇒ Object
Returns the value of attribute luminosity.
-
#sweep_angle ⇒ Object
readonly
Returns the value of attribute sweep_angle.
Instance Method Summary collapse
- #blazing? ⇒ Boolean
- #brighten!(rate: Constants::LUMINOSITY_RATE) ⇒ Object
- #dim!(rate: Constants::LUMINOSITY_RATE) ⇒ Object
- #extinguished? ⇒ Boolean
-
#initialize(beacon_type:, domain:, content:, luminosity: nil, sweep_angle: nil) ⇒ Beacon
constructor
A new instance of Beacon.
- #luminosity_label ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(beacon_type:, domain:, content:, luminosity: nil, sweep_angle: nil) ⇒ Beacon
Returns a new instance of Beacon.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/beacon.rb', line 13 def initialize(beacon_type:, domain:, content:, luminosity: nil, sweep_angle: nil) validate_beacon_type!(beacon_type) @id = SecureRandom.uuid @beacon_type = beacon_type.to_sym @domain = domain.to_s @content = content.to_s @luminosity = (luminosity || 0.7).to_f.clamp(0.0, 1.0).round(10) @sweep_angle = (sweep_angle || 0.0).to_f.clamp(0.0, 360.0).round(10) @lit_at = Time.now.utc end |
Instance Attribute Details
#beacon_type ⇒ Object (readonly)
Returns the value of attribute beacon_type.
10 11 12 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/beacon.rb', line 10 def beacon_type @beacon_type end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
10 11 12 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/beacon.rb', line 10 def content @content end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
10 11 12 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/beacon.rb', line 10 def domain @domain end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/beacon.rb', line 10 def id @id end |
#lit_at ⇒ Object (readonly)
Returns the value of attribute lit_at.
10 11 12 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/beacon.rb', line 10 def lit_at @lit_at end |
#luminosity ⇒ Object
Returns the value of attribute luminosity.
11 12 13 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/beacon.rb', line 11 def luminosity @luminosity end |
#sweep_angle ⇒ Object (readonly)
Returns the value of attribute sweep_angle.
10 11 12 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/beacon.rb', line 10 def sweep_angle @sweep_angle end |
Instance Method Details
#blazing? ⇒ Boolean
38 39 40 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/beacon.rb', line 38 def blazing? @luminosity >= 0.9 end |
#brighten!(rate: Constants::LUMINOSITY_RATE) ⇒ Object
24 25 26 27 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/beacon.rb', line 24 def brighten!(rate: Constants::LUMINOSITY_RATE) @luminosity = (@luminosity + rate).clamp(0.0, 1.0).round(10) self end |
#dim!(rate: Constants::LUMINOSITY_RATE) ⇒ Object
29 30 31 32 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/beacon.rb', line 29 def dim!(rate: Constants::LUMINOSITY_RATE) @luminosity = (@luminosity - rate).clamp(0.0, 1.0).round(10) self end |
#extinguished? ⇒ Boolean
34 35 36 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/beacon.rb', line 34 def extinguished? @luminosity <= 0.0 end |
#luminosity_label ⇒ Object
42 43 44 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/beacon.rb', line 42 def luminosity_label Constants.label_for(Constants::LUMINOSITY_LABELS, @luminosity) end |
#to_h ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/legion/extensions/agentic/attention/lighthouse/helpers/beacon.rb', line 46 def to_h { id: @id, beacon_type: @beacon_type, domain: @domain, content: @content, luminosity: @luminosity, sweep_angle: @sweep_angle, luminosity_label: luminosity_label, extinguished: extinguished?, blazing: blazing?, lit_at: @lit_at } end |