Class: Legion::Extensions::Agentic::Memory::Paleontology::Helpers::Fossil
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Memory::Paleontology::Helpers::Fossil
- Defined in:
- lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#discovered_at ⇒ Object
readonly
Returns the value of attribute discovered_at.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#era ⇒ Object
readonly
Returns the value of attribute era.
-
#extinct_at ⇒ Object
readonly
Returns the value of attribute extinct_at.
-
#extinction_cause ⇒ Object
readonly
Returns the value of attribute extinction_cause.
-
#fossil_type ⇒ Object
readonly
Returns the value of attribute fossil_type.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#lineage_ids ⇒ Object
readonly
Returns the value of attribute lineage_ids.
-
#preservation ⇒ Object
Returns the value of attribute preservation.
-
#significance ⇒ Object
Returns the value of attribute significance.
-
#stratum_depth ⇒ Object
readonly
Returns the value of attribute stratum_depth.
Instance Method Summary collapse
- #ancient? ⇒ Boolean
- #erode!(rate: Constants::FOSSILIZATION_RATE) ⇒ Object
- #imprint? ⇒ Boolean
-
#initialize(fossil_type:, domain:, content:, extinction_cause:, era: nil, stratum_depth: 0, preservation: nil, significance: nil) ⇒ Fossil
constructor
A new instance of Fossil.
- #keystone? ⇒ Boolean
- #link_lineage(other_id) ⇒ Object
- #preservation_label ⇒ Object
- #reinforce!(boost: 0.1) ⇒ Object
- #significance_label ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(fossil_type:, domain:, content:, extinction_cause:, era: nil, stratum_depth: 0, preservation: nil, significance: nil) ⇒ Fossil
Returns a new instance of Fossil.
15 16 17 18 19 20 21 22 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 15 def initialize(fossil_type:, domain:, content:, extinction_cause:, era: nil, stratum_depth: 0, preservation: nil, significance: nil) validate_type!(fossil_type) validate_cause!(extinction_cause) assign_core(fossil_type, domain, content, extinction_cause) (era, stratum_depth, preservation, significance) end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
10 11 12 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 10 def content @content end |
#discovered_at ⇒ Object (readonly)
Returns the value of attribute discovered_at.
10 11 12 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 10 def discovered_at @discovered_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
10 11 12 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 10 def domain @domain end |
#era ⇒ Object (readonly)
Returns the value of attribute era.
10 11 12 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 10 def era @era end |
#extinct_at ⇒ Object (readonly)
Returns the value of attribute extinct_at.
10 11 12 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 10 def extinct_at @extinct_at end |
#extinction_cause ⇒ Object (readonly)
Returns the value of attribute extinction_cause.
10 11 12 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 10 def extinction_cause @extinction_cause end |
#fossil_type ⇒ Object (readonly)
Returns the value of attribute fossil_type.
10 11 12 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 10 def fossil_type @fossil_type end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 10 def id @id end |
#lineage_ids ⇒ Object (readonly)
Returns the value of attribute lineage_ids.
10 11 12 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 10 def lineage_ids @lineage_ids end |
#preservation ⇒ Object
Returns the value of attribute preservation.
13 14 15 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 13 def preservation @preservation end |
#significance ⇒ Object
Returns the value of attribute significance.
13 14 15 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 13 def significance @significance end |
#stratum_depth ⇒ Object (readonly)
Returns the value of attribute stratum_depth.
10 11 12 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 10 def stratum_depth @stratum_depth end |
Instance Method Details
#ancient? ⇒ Boolean
42 43 44 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 42 def ancient? (Time.now.utc - @extinct_at) > 5_000_000 end |
#erode!(rate: Constants::FOSSILIZATION_RATE) ⇒ Object
24 25 26 27 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 24 def erode!(rate: Constants::FOSSILIZATION_RATE) @preservation = (@preservation - rate.abs).clamp(0.0, 1.0).round(10) self end |
#imprint? ⇒ Boolean
34 35 36 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 34 def imprint? @preservation < 0.2 end |
#keystone? ⇒ Boolean
38 39 40 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 38 def keystone? @significance >= 0.8 end |
#link_lineage(other_id) ⇒ Object
54 55 56 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 54 def link_lineage(other_id) @lineage_ids << other_id unless @lineage_ids.include?(other_id) end |
#preservation_label ⇒ Object
46 47 48 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 46 def preservation_label Constants.label_for(Constants::PRESERVATION_LABELS, @preservation) end |
#reinforce!(boost: 0.1) ⇒ Object
29 30 31 32 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 29 def reinforce!(boost: 0.1) @significance = (@significance + boost.abs).clamp(0.0, 1.0).round(10) self end |
#significance_label ⇒ Object
50 51 52 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 50 def significance_label Constants.label_for(Constants::SIGNIFICANCE_LABELS, @significance) end |
#to_h ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 58 def to_h { id: @id, fossil_type: @fossil_type, domain: @domain, content: @content, extinction_cause: @extinction_cause, era: @era, stratum_depth: @stratum_depth, preservation: @preservation, preservation_label: preservation_label, significance: @significance, significance_label: significance_label, discovered_at: @discovered_at, extinct_at: @extinct_at, lineage_ids: @lineage_ids, imprint: imprint?, keystone: keystone?, ancient: ancient? } end |