Class: Legion::Gaia::CognitiveBus::Signal
- Inherits:
-
Object
- Object
- Legion::Gaia::CognitiveBus::Signal
- Defined in:
- lib/legion/gaia/cognitive_bus.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#precision ⇒ Object
readonly
Returns the value of attribute precision.
-
#salience ⇒ Object
Returns the value of attribute salience.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#status ⇒ Object
Returns the value of attribute status.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type:, data:, precision:, salience:, source:, status: :pending) ⇒ Signal
constructor
A new instance of Signal.
- #to_h ⇒ Object
- #weighted_salience ⇒ Object
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_at ⇒ Object (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 |
#data ⇒ Object (readonly)
Returns the value of attribute data.
23 24 25 |
# File 'lib/legion/gaia/cognitive_bus.rb', line 23 def data @data end |
#precision ⇒ Object (readonly)
Returns the value of attribute precision.
23 24 25 |
# File 'lib/legion/gaia/cognitive_bus.rb', line 23 def precision @precision end |
#salience ⇒ Object
Returns the value of attribute salience.
22 23 24 |
# File 'lib/legion/gaia/cognitive_bus.rb', line 22 def salience @salience end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
23 24 25 |
# File 'lib/legion/gaia/cognitive_bus.rb', line 23 def source @source end |
#status ⇒ Object
Returns the value of attribute status.
22 23 24 |
# File 'lib/legion/gaia/cognitive_bus.rb', line 22 def status @status end |
#type ⇒ Object (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_h ⇒ Object
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_salience ⇒ Object
35 36 37 |
# File 'lib/legion/gaia/cognitive_bus.rb', line 35 def weighted_salience @salience * @precision end |