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 ⇒ Object
readonly
Returns the value of attribute 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.
34 35 36 37 38 |
# File 'lib/gruf/interceptors/timer.rb', line 34 def initialize(, elapsed, successful) @message = @elapsed = elapsed.to_f @successful = successful ? true : false end |
Instance Attribute Details
#elapsed ⇒ Object (readonly)
Returns the value of attribute elapsed.
27 28 29 |
# File 'lib/gruf/interceptors/timer.rb', line 27 def elapsed @elapsed end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
26 27 28 |
# File 'lib/gruf/interceptors/timer.rb', line 26 def @message end |
Instance Method Details
#elapsed_rounded(precision: 2) ⇒ Float
Return the execution time rounded to a specified precision
60 61 62 |
# File 'lib/gruf/interceptors/timer.rb', line 60 def elapsed_rounded(precision: 2) @elapsed.to_f.round(precision) end |
#message_class_name ⇒ String
Returns The name of the message class.
50 51 52 |
# File 'lib/gruf/interceptors/timer.rb', line 50 def @message.class.name end |
#successful? ⇒ Boolean
Returns True if this was a successful request.
43 44 45 |
# File 'lib/gruf/interceptors/timer.rb', line 43 def successful? @successful end |