Class: Peek::Views::Faraday
- Inherits:
-
View
- Object
- View
- Peek::Views::Faraday
- Defined in:
- lib/peek/views/faraday.rb
Instance Method Summary collapse
- #formatted_duration ⇒ Object
-
#initialize(options = {}) ⇒ Faraday
constructor
A new instance of Faraday.
- #results ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Faraday
Returns a new instance of Faraday.
6 7 8 9 10 11 12 |
# File 'lib/peek/views/faraday.rb', line 6 def initialize( = {}) @duration = Atomic.new(0) @calls = Atomic.new(0) @requests = Atomic.new([].freeze) setup_subscribers end |
Instance Method Details
#formatted_duration ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/peek/views/faraday.rb', line 14 def formatted_duration ms = @duration.value if ms >= 1000 "%.2fms" % ms else "%.0fms" % ms end end |
#results ⇒ Object
23 24 25 |
# File 'lib/peek/views/faraday.rb', line 23 def results { :duration => formatted_duration, :calls => @calls.value, :requests => @requests.value } end |