Class: Legion::Gaia::CognitiveBus::Signal

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/gaia/cognitive_bus.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, data:, precision:, salience:, source:, status: :pending) ⇒ Signal

Returns a new instance of Signal.



25
26
27
28
29
30
31
32
33
# File 'lib/legion/gaia/cognitive_bus.rb', line 25

def initialize(type:, data:, precision:, salience:, source:, status: :pending)
  @type      = type
  @data      = data
  @precision = precision
  @salience  = salience
  @source    = source
  @status    = status
  @created_at = Time.now.utc
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



23
24
25
# File 'lib/legion/gaia/cognitive_bus.rb', line 23

def created_at
  @created_at
end

#dataObject (readonly)

Returns the value of attribute data.



23
24
25
# File 'lib/legion/gaia/cognitive_bus.rb', line 23

def data
  @data
end

#precisionObject (readonly)

Returns the value of attribute precision.



23
24
25
# File 'lib/legion/gaia/cognitive_bus.rb', line 23

def precision
  @precision
end

#salienceObject

Returns the value of attribute salience.



22
23
24
# File 'lib/legion/gaia/cognitive_bus.rb', line 22

def salience
  @salience
end

#sourceObject (readonly)

Returns the value of attribute source.



23
24
25
# File 'lib/legion/gaia/cognitive_bus.rb', line 23

def source
  @source
end

#statusObject

Returns the value of attribute status.



22
23
24
# File 'lib/legion/gaia/cognitive_bus.rb', line 22

def status
  @status
end

#typeObject (readonly)

Returns the value of attribute type.



23
24
25
# File 'lib/legion/gaia/cognitive_bus.rb', line 23

def type
  @type
end

Instance Method Details

#to_hObject



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/legion/gaia/cognitive_bus.rb', line 39

def to_h
  {
    type: @type,
    data: @data,
    precision: @precision,
    salience: @salience,
    source: @source,
    status: @status,
    weighted: weighted_salience.round(4)
  }
end

#weighted_salienceObject



35
36
37
# File 'lib/legion/gaia/cognitive_bus.rb', line 35

def weighted_salience
  @salience * @precision
end