Class: Legion::Extensions::Agentic::Integration::Mosaic::Helpers::Tessera
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Integration::Mosaic::Helpers::Tessera
- Defined in:
- lib/legion/extensions/agentic/integration/mosaic/helpers/tessera.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#fit_quality ⇒ Object
Returns the value of attribute fit_quality.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#material ⇒ Object
readonly
Returns the value of attribute material.
-
#mosaic_id ⇒ Object
readonly
Returns the value of attribute mosaic_id.
-
#placed_at ⇒ Object
readonly
Returns the value of attribute placed_at.
Instance Method Summary collapse
-
#initialize(material:, domain:, content:, color: nil, fit_quality: nil) ⇒ Tessera
constructor
A new instance of Tessera.
- #loose? ⇒ Boolean
- #perfect_fit? ⇒ Boolean
- #place!(mosaic_id) ⇒ Object
- #placed? ⇒ Boolean
- #poor_fit? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(material:, domain:, content:, color: nil, fit_quality: nil) ⇒ Tessera
Returns a new instance of Tessera.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/legion/extensions/agentic/integration/mosaic/helpers/tessera.rb', line 14 def initialize(material:, domain:, content:, color: nil, fit_quality: nil) validate_material!(material) @id = SecureRandom.uuid @material = material.to_sym @domain = domain.to_sym @content = content.to_s @color = (color || random_color).to_sym @fit_quality = (fit_quality || 0.5).to_f.clamp(0.0, 1.0).round(10) @placed_at = nil @mosaic_id = nil end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
10 11 12 |
# File 'lib/legion/extensions/agentic/integration/mosaic/helpers/tessera.rb', line 10 def color @color end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
10 11 12 |
# File 'lib/legion/extensions/agentic/integration/mosaic/helpers/tessera.rb', line 10 def content @content end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
10 11 12 |
# File 'lib/legion/extensions/agentic/integration/mosaic/helpers/tessera.rb', line 10 def domain @domain end |
#fit_quality ⇒ Object
Returns the value of attribute fit_quality.
12 13 14 |
# File 'lib/legion/extensions/agentic/integration/mosaic/helpers/tessera.rb', line 12 def fit_quality @fit_quality end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/legion/extensions/agentic/integration/mosaic/helpers/tessera.rb', line 10 def id @id end |
#material ⇒ Object (readonly)
Returns the value of attribute material.
10 11 12 |
# File 'lib/legion/extensions/agentic/integration/mosaic/helpers/tessera.rb', line 10 def material @material end |
#mosaic_id ⇒ Object (readonly)
Returns the value of attribute mosaic_id.
10 11 12 |
# File 'lib/legion/extensions/agentic/integration/mosaic/helpers/tessera.rb', line 10 def mosaic_id @mosaic_id end |
#placed_at ⇒ Object (readonly)
Returns the value of attribute placed_at.
10 11 12 |
# File 'lib/legion/extensions/agentic/integration/mosaic/helpers/tessera.rb', line 10 def placed_at @placed_at end |
Instance Method Details
#loose? ⇒ Boolean
37 38 39 |
# File 'lib/legion/extensions/agentic/integration/mosaic/helpers/tessera.rb', line 37 def loose? @mosaic_id.nil? end |
#perfect_fit? ⇒ Boolean
41 42 43 |
# File 'lib/legion/extensions/agentic/integration/mosaic/helpers/tessera.rb', line 41 def perfect_fit? @fit_quality >= 0.9 end |
#place!(mosaic_id) ⇒ Object
27 28 29 30 31 |
# File 'lib/legion/extensions/agentic/integration/mosaic/helpers/tessera.rb', line 27 def place!(mosaic_id) @mosaic_id = mosaic_id @placed_at = Time.now.utc self end |
#placed? ⇒ Boolean
33 34 35 |
# File 'lib/legion/extensions/agentic/integration/mosaic/helpers/tessera.rb', line 33 def placed? !@mosaic_id.nil? end |
#poor_fit? ⇒ Boolean
45 46 47 |
# File 'lib/legion/extensions/agentic/integration/mosaic/helpers/tessera.rb', line 45 def poor_fit? @fit_quality < 0.3 end |
#to_h ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/legion/extensions/agentic/integration/mosaic/helpers/tessera.rb', line 49 def to_h { id: @id, material: @material, domain: @domain, content: @content, color: @color, fit_quality: @fit_quality, placed: placed?, loose: loose?, perfect_fit: perfect_fit?, poor_fit: poor_fit?, mosaic_id: @mosaic_id, placed_at: @placed_at } end |