Class: Kaisoku::Entity
- Inherits:
-
Struct
- Object
- Struct
- Kaisoku::Entity
- Defined in:
- lib/kaisoku/entity.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#avg_duration_ms ⇒ Object
Returns the value of attribute avg_duration_ms.
-
#failure_count ⇒ Object
Returns the value of attribute failure_count.
-
#file ⇒ Object
Returns the value of attribute file.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#last_failed_at ⇒ Object
Returns the value of attribute last_failed_at.
-
#last_status ⇒ Object
Returns the value of attribute last_status.
-
#line ⇒ Object
Returns the value of attribute line.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #failed? ⇒ Boolean
- #hash ⇒ Object
- #id ⇒ Object
-
#initialize(adapter:, identifier:, file:, line: nil, avg_duration_ms: nil, last_status: nil, last_failed_at: nil, failure_count: 0) ⇒ Entity
constructor
A new instance of Entity.
- #with_runtime(avg_duration_ms: self.avg_duration_ms, last_status: self.last_status, last_failed_at: self.last_failed_at, failure_count: self.failure_count) ⇒ Object
Constructor Details
#initialize(adapter:, identifier:, file:, line: nil, avg_duration_ms: nil, last_status: nil, last_failed_at: nil, failure_count: 0) ⇒ Entity
Returns a new instance of Entity.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/kaisoku/entity.rb', line 15 def initialize( adapter:, identifier:, file:, line: nil, avg_duration_ms: nil, last_status: nil, last_failed_at: nil, failure_count: 0 ) super( adapter: adapter.to_s, identifier: identifier.to_s, file: normalize_file(file), line: line, avg_duration_ms: avg_duration_ms, last_status: last_status, last_failed_at: last_failed_at, failure_count: failure_count.to_i ) end |
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter
4 5 6 |
# File 'lib/kaisoku/entity.rb', line 4 def adapter @adapter end |
#avg_duration_ms ⇒ Object
Returns the value of attribute avg_duration_ms
4 5 6 |
# File 'lib/kaisoku/entity.rb', line 4 def avg_duration_ms @avg_duration_ms end |
#failure_count ⇒ Object
Returns the value of attribute failure_count
4 5 6 |
# File 'lib/kaisoku/entity.rb', line 4 def failure_count @failure_count end |
#file ⇒ Object
Returns the value of attribute file
4 5 6 |
# File 'lib/kaisoku/entity.rb', line 4 def file @file end |
#identifier ⇒ Object
Returns the value of attribute identifier
4 5 6 |
# File 'lib/kaisoku/entity.rb', line 4 def identifier @identifier end |
#last_failed_at ⇒ Object
Returns the value of attribute last_failed_at
4 5 6 |
# File 'lib/kaisoku/entity.rb', line 4 def last_failed_at @last_failed_at end |
#last_status ⇒ Object
Returns the value of attribute last_status
4 5 6 |
# File 'lib/kaisoku/entity.rb', line 4 def last_status @last_status end |
#line ⇒ Object
Returns the value of attribute line
4 5 6 |
# File 'lib/kaisoku/entity.rb', line 4 def line @line end |
Instance Method Details
#eql?(other) ⇒ Boolean
63 64 65 |
# File 'lib/kaisoku/entity.rb', line 63 def eql?(other) other.is_a?(Entity) && other.id == id end |
#failed? ⇒ Boolean
41 42 43 |
# File 'lib/kaisoku/entity.rb', line 41 def failed? last_status == 'failed' end |
#hash ⇒ Object
67 68 69 |
# File 'lib/kaisoku/entity.rb', line 67 def hash id.hash end |
#id ⇒ Object
37 38 39 |
# File 'lib/kaisoku/entity.rb', line 37 def id "#{adapter}:#{identifier}" end |
#with_runtime(avg_duration_ms: self.avg_duration_ms, last_status: self.last_status, last_failed_at: self.last_failed_at, failure_count: self.failure_count) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/kaisoku/entity.rb', line 45 def with_runtime( avg_duration_ms: self.avg_duration_ms, last_status: self.last_status, last_failed_at: self.last_failed_at, failure_count: self.failure_count ) self.class.new( adapter: adapter, identifier: identifier, file: file, line: line, avg_duration_ms: avg_duration_ms, last_status: last_status, last_failed_at: last_failed_at, failure_count: failure_count ) end |