Class: Gruf::Interceptors::Timer::Result
- Inherits:
-
Object
- Object
- Gruf::Interceptors::Timer::Result
- Defined in:
- lib/gruf/interceptors/timer.rb
Overview
Represents a timed result for an interceptor
Instance Attribute Summary collapse
-
#elapsed ⇒ r
readonly
Elapsed.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#elapsed_rounded(precision: 2) ⇒ Float
Return the execution time rounded to a specified precision.
-
#initialize(message, elapsed, successful) ⇒ Result
constructor
A new instance of Result.
-
#message_class_name ⇒ String
The name of the message class.
-
#successful? ⇒ Boolean
True if this was a successful request.
Constructor Details
#initialize(message, elapsed, successful) ⇒ Result
Returns a new instance of Result.
43 44 45 46 47 |
# File 'lib/gruf/interceptors/timer.rb', line 43 def initialize(, elapsed, successful) @message = @elapsed = elapsed.to_f @successful = successful ? true : false end |
Instance Attribute Details
#elapsed ⇒ r (readonly)
Returns elapsed @return [Float] The time elapsed for this interceptor to execute.
36 37 38 |
# File 'lib/gruf/interceptors/timer.rb', line 36 def elapsed @elapsed end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
33 34 35 |
# File 'lib/gruf/interceptors/timer.rb', line 33 def @message end |
Instance Method Details
#elapsed_rounded(precision: 2) ⇒ Float
Return the execution time rounded to a specified precision
69 70 71 |
# File 'lib/gruf/interceptors/timer.rb', line 69 def elapsed_rounded(precision: 2) @elapsed.to_f.round(precision) end |
#message_class_name ⇒ String
Returns The name of the message class.
59 60 61 |
# File 'lib/gruf/interceptors/timer.rb', line 59 def @message.class.name.to_s end |
#successful? ⇒ Boolean
Returns True if this was a successful request.
52 53 54 |
# File 'lib/gruf/interceptors/timer.rb', line 52 def successful? @successful end |