Class: Legion::Extensions::Agentic::Memory::Paleontology::Helpers::Excavation
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Memory::Paleontology::Helpers::Excavation
- Defined in:
- lib/legion/extensions/agentic/memory/paleontology/helpers/excavation.rb
Instance Attribute Summary collapse
-
#completed_at ⇒ Object
readonly
Returns the value of attribute completed_at.
-
#fossils_found ⇒ Object
readonly
Returns the value of attribute fossils_found.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#started_at ⇒ Object
readonly
Returns the value of attribute started_at.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#target_stratum ⇒ Object
readonly
Returns the value of attribute target_stratum.
Instance Method Summary collapse
- #complete! ⇒ Object
- #completed? ⇒ Boolean
-
#initialize(target_stratum:) ⇒ Excavation
constructor
A new instance of Excavation.
- #record_find!(fossil) ⇒ Object
- #to_h ⇒ Object
- #yield_rate ⇒ Object
Constructor Details
#initialize(target_stratum:) ⇒ Excavation
Returns a new instance of Excavation.
13 14 15 16 17 18 19 20 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/excavation.rb', line 13 def initialize(target_stratum:) @id = SecureRandom.uuid @target_stratum = target_stratum.to_i.clamp(0, 4) @fossils_found = [] @started_at = Time.now.utc @completed_at = nil @status = :in_progress end |
Instance Attribute Details
#completed_at ⇒ Object (readonly)
Returns the value of attribute completed_at.
10 11 12 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/excavation.rb', line 10 def completed_at @completed_at end |
#fossils_found ⇒ Object (readonly)
Returns the value of attribute fossils_found.
10 11 12 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/excavation.rb', line 10 def fossils_found @fossils_found end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/excavation.rb', line 10 def id @id end |
#started_at ⇒ Object (readonly)
Returns the value of attribute started_at.
10 11 12 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/excavation.rb', line 10 def started_at @started_at end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
10 11 12 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/excavation.rb', line 10 def status @status end |
#target_stratum ⇒ Object (readonly)
Returns the value of attribute target_stratum.
10 11 12 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/excavation.rb', line 10 def target_stratum @target_stratum end |
Instance Method Details
#complete! ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/excavation.rb', line 26 def complete! return false if @status == :completed @completed_at = Time.now.utc @status = :completed true end |
#completed? ⇒ Boolean
34 35 36 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/excavation.rb', line 34 def completed? @status == :completed end |
#record_find!(fossil) ⇒ Object
22 23 24 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/excavation.rb', line 22 def record_find!(fossil) @fossils_found << fossil end |
#to_h ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/excavation.rb', line 44 def to_h { id: @id, target_stratum: @target_stratum, stratum_label: Constants::STRATUM_LABELS[@target_stratum], fossils_count: @fossils_found.size, yield_rate: yield_rate.round(10), status: @status, started_at: @started_at, completed_at: @completed_at } end |
#yield_rate ⇒ Object
38 39 40 41 42 |
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/excavation.rb', line 38 def yield_rate return 0.0 if @fossils_found.empty? @fossils_found.sum(&:significance) / @fossils_found.size end |