Class: Legion::Extensions::Agentic::Self::RelationshipArc::Helpers::Milestone
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Self::RelationshipArc::Helpers::Milestone
- Defined in:
- lib/legion/extensions/agentic/self/relationship_arc/helpers/milestone.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#significance ⇒ Object
readonly
Returns the value of attribute significance.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type:, description:, significance:, id: nil, created_at: nil) ⇒ Milestone
constructor
A new instance of Milestone.
- #to_h ⇒ Object
Constructor Details
#initialize(type:, description:, significance:, id: nil, created_at: nil) ⇒ Milestone
Returns a new instance of Milestone.
14 15 16 17 18 19 20 |
# File 'lib/legion/extensions/agentic/self/relationship_arc/helpers/milestone.rb', line 14 def initialize(type:, description:, significance:, id: nil, created_at: nil) @id = id || SecureRandom.uuid @type = type.to_sym @description = description @significance = significance.to_f.clamp(0.0, 1.0) @created_at = created_at || Time.now.utc end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/relationship_arc/helpers/milestone.rb', line 12 def created_at @created_at end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/relationship_arc/helpers/milestone.rb', line 12 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/relationship_arc/helpers/milestone.rb', line 12 def id @id end |
#significance ⇒ Object (readonly)
Returns the value of attribute significance.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/relationship_arc/helpers/milestone.rb', line 12 def significance @significance end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/relationship_arc/helpers/milestone.rb', line 12 def type @type end |
Class Method Details
.from_h(hash) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/legion/extensions/agentic/self/relationship_arc/helpers/milestone.rb', line 27 def self.from_h(hash) new( id: hash[:id], type: hash[:type], description: hash[:description], significance: hash[:significance], created_at: hash[:created_at] ? Time.parse(hash[:created_at].to_s) : nil ) end |
Instance Method Details
#to_h ⇒ Object
22 23 24 25 |
# File 'lib/legion/extensions/agentic/self/relationship_arc/helpers/milestone.rb', line 22 def to_h { id: @id, type: @type, description: @description, significance: @significance, created_at: @created_at.iso8601 } end |