Class: Legion::Extensions::Agentic::Integration::Mycelium::Helpers::FruitingBody

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/agentic/integration/mycelium/helpers/fruiting_body.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fruiting_type:, source_node_id:, content:, potency: 0.5) ⇒ FruitingBody

Returns a new instance of FruitingBody.



13
14
15
16
17
18
19
20
21
22
# File 'lib/legion/extensions/agentic/integration/mycelium/helpers/fruiting_body.rb', line 13

def initialize(fruiting_type:, source_node_id:,
               content:, potency: 0.5)
  validate_type!(fruiting_type)
  @id             = SecureRandom.uuid
  @fruiting_type  = fruiting_type.to_sym
  @source_node_id = source_node_id
  @content        = content.to_s
  @potency        = potency.to_f.clamp(0.0, 1.0).round(10)
  @emerged_at     = Time.now.utc
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



10
11
12
# File 'lib/legion/extensions/agentic/integration/mycelium/helpers/fruiting_body.rb', line 10

def content
  @content
end

#emerged_atObject (readonly)

Returns the value of attribute emerged_at.



10
11
12
# File 'lib/legion/extensions/agentic/integration/mycelium/helpers/fruiting_body.rb', line 10

def emerged_at
  @emerged_at
end

#fruiting_typeObject (readonly)

Returns the value of attribute fruiting_type.



10
11
12
# File 'lib/legion/extensions/agentic/integration/mycelium/helpers/fruiting_body.rb', line 10

def fruiting_type
  @fruiting_type
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/legion/extensions/agentic/integration/mycelium/helpers/fruiting_body.rb', line 10

def id
  @id
end

#potencyObject (readonly)

Returns the value of attribute potency.



10
11
12
# File 'lib/legion/extensions/agentic/integration/mycelium/helpers/fruiting_body.rb', line 10

def potency
  @potency
end

#source_node_idObject (readonly)

Returns the value of attribute source_node_id.



10
11
12
# File 'lib/legion/extensions/agentic/integration/mycelium/helpers/fruiting_body.rb', line 10

def source_node_id
  @source_node_id
end

Instance Method Details

#to_hObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/legion/extensions/agentic/integration/mycelium/helpers/fruiting_body.rb', line 24

def to_h
  {
    id:             @id,
    fruiting_type:  @fruiting_type,
    source_node_id: @source_node_id,
    content:        @content,
    potency:        @potency,
    emerged_at:     @emerged_at
  }
end