Class: Legion::Extensions::Agentic::Attention::Kaleidoscope::Helpers::Facet

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(facet_type:, domain:, content:, brilliance: nil, transparency: nil, angle: nil) ⇒ Facet

Returns a new instance of Facet.



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/facet.rb', line 14

def initialize(facet_type:, domain:, content:,
               brilliance: nil, transparency: nil, angle: nil)
  validate_facet_type!(facet_type)
  @id           = SecureRandom.uuid
  @facet_type   = facet_type.to_sym
  @domain       = domain.to_sym
  @content      = content.to_s
  @brilliance   = (brilliance || 0.7).to_f.clamp(0.0, 1.0).round(10)
  @transparency = (transparency || 0.5).to_f.clamp(0.0, 1.0).round(10)
  @angle        = (angle || 0.0).to_f.clamp(0.0, 360.0).round(10)
  @created_at   = Time.now.utc
end

Instance Attribute Details

#angleObject (readonly)

Returns the value of attribute angle.



10
11
12
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/facet.rb', line 10

def angle
  @angle
end

#brillianceObject

Returns the value of attribute brilliance.



12
13
14
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/facet.rb', line 12

def brilliance
  @brilliance
end

#contentObject (readonly)

Returns the value of attribute content.



10
11
12
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/facet.rb', line 10

def content
  @content
end

#created_atObject (readonly)

Returns the value of attribute created_at.



10
11
12
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/facet.rb', line 10

def created_at
  @created_at
end

#domainObject (readonly)

Returns the value of attribute domain.



10
11
12
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/facet.rb', line 10

def domain
  @domain
end

#facet_typeObject (readonly)

Returns the value of attribute facet_type.



10
11
12
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/facet.rb', line 10

def facet_type
  @facet_type
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/facet.rb', line 10

def id
  @id
end

#transparencyObject

Returns the value of attribute transparency.



12
13
14
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/facet.rb', line 12

def transparency
  @transparency
end

Instance Method Details

#brilliance_labelObject



55
56
57
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/facet.rb', line 55

def brilliance_label
  Constants.label_for(Constants::BRILLIANCE_LABELS, @brilliance)
end

#clear?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/facet.rb', line 51

def clear?
  @transparency >= 0.8
end

#dark?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/facet.rb', line 43

def dark?
  @brilliance < 0.2
end

#dazzling?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/facet.rb', line 39

def dazzling?
  @brilliance >= Constants::BRILLIANCE_THRESHOLD
end

#opaque?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/facet.rb', line 47

def opaque?
  @transparency < 0.2
end

#polish!(rate: 0.1) ⇒ Object



31
32
33
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/facet.rb', line 31

def polish!(rate: 0.1)
  @brilliance = (@brilliance + rate.abs).clamp(0.0, 1.0).round(10)
end

#rotate!(degrees: Constants::ROTATION_STEP * 360) ⇒ Object



27
28
29
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/facet.rb', line 27

def rotate!(degrees: Constants::ROTATION_STEP * 360)
  @angle = ((@angle + degrees.abs) % 360.0).round(10)
end

#tarnish!(rate: Constants::DECAY_RATE) ⇒ Object



35
36
37
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/facet.rb', line 35

def tarnish!(rate: Constants::DECAY_RATE)
  @brilliance = (@brilliance - rate.abs).clamp(0.0, 1.0).round(10)
end

#to_hObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/legion/extensions/agentic/attention/kaleidoscope/helpers/facet.rb', line 59

def to_h
  {
    id:               @id,
    facet_type:       @facet_type,
    domain:           @domain,
    content:          @content,
    brilliance:       @brilliance,
    transparency:     @transparency,
    angle:            @angle,
    brilliance_label: brilliance_label,
    dazzling:         dazzling?,
    dark:             dark?,
    created_at:       @created_at
  }
end