Class: Desiru::Core::Trace
- Inherits:
-
Object
- Object
- Desiru::Core::Trace
- Defined in:
- lib/desiru/core/trace.rb
Instance Attribute Summary collapse
-
#inputs ⇒ Object
readonly
Returns the value of attribute inputs.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#module_name ⇒ Object
readonly
Returns the value of attribute module_name.
-
#outputs ⇒ Object
readonly
Returns the value of attribute outputs.
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #duration ⇒ Object
- #duration_ms ⇒ Object
- #error ⇒ Object
- #error? ⇒ Boolean
-
#initialize(module_name:, signature:, inputs: {}, outputs: {}, metadata: {}) ⇒ Trace
constructor
A new instance of Trace.
- #success? ⇒ Boolean
- #to_example ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(module_name:, signature:, inputs: {}, outputs: {}, metadata: {}) ⇒ Trace
Returns a new instance of Trace.
8 9 10 11 12 13 14 15 |
# File 'lib/desiru/core/trace.rb', line 8 def initialize(module_name:, signature:, inputs: {}, outputs: {}, metadata: {}) @module_name = module_name @signature = signature @inputs = inputs @outputs = outputs = = Time.now end |
Instance Attribute Details
#inputs ⇒ Object (readonly)
Returns the value of attribute inputs.
6 7 8 |
# File 'lib/desiru/core/trace.rb', line 6 def inputs @inputs end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
6 7 8 |
# File 'lib/desiru/core/trace.rb', line 6 def end |
#module_name ⇒ Object (readonly)
Returns the value of attribute module_name.
6 7 8 |
# File 'lib/desiru/core/trace.rb', line 6 def module_name @module_name end |
#outputs ⇒ Object (readonly)
Returns the value of attribute outputs.
6 7 8 |
# File 'lib/desiru/core/trace.rb', line 6 def outputs @outputs end |
#signature ⇒ Object (readonly)
Returns the value of attribute signature.
6 7 8 |
# File 'lib/desiru/core/trace.rb', line 6 def signature @signature end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
6 7 8 |
# File 'lib/desiru/core/trace.rb', line 6 def end |
Instance Method Details
#==(other) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/desiru/core/trace.rb', line 54 def ==(other) return false unless other.is_a?(self.class) @module_name == other.module_name && @signature == other.signature && @inputs == other.inputs && @outputs == other.outputs && == other. end |
#duration ⇒ Object
44 45 46 |
# File 'lib/desiru/core/trace.rb', line 44 def duration [:duration] end |
#duration_ms ⇒ Object
48 49 50 51 52 |
# File 'lib/desiru/core/trace.rb', line 48 def duration_ms return 0 unless duration (duration * 1000).to_f end |
#error ⇒ Object
40 41 42 |
# File 'lib/desiru/core/trace.rb', line 40 def error [:error] end |
#error? ⇒ Boolean
36 37 38 |
# File 'lib/desiru/core/trace.rb', line 36 def error? .key?(:error) end |
#success? ⇒ Boolean
32 33 34 |
# File 'lib/desiru/core/trace.rb', line 32 def success? [:success] != false end |
#to_example ⇒ Object
28 29 30 |
# File 'lib/desiru/core/trace.rb', line 28 def to_example Example.new(**@inputs, **@outputs) end |
#to_h ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/desiru/core/trace.rb', line 17 def to_h { module_name: @module_name, signature: @signature.is_a?(String) ? @signature : @signature.to_h, inputs: @inputs, outputs: @outputs, metadata: , timestamp: } end |