class MovidaEvents::Stats
Tracks polling stats
Attributes
events[R]
The number of events processed
@return [Integer] The event count
last[R]
The last-processed event ID
`nil` if no events have been processed
@return [Integer,nil] The event ID
request_events[R]
The number of events processed in the current request
@return [Integer] The request event count
requests[R]
The number of requests made to the API
@return [Integer] The request count
Public Class Methods
new(last = nil)
click to toggle source
Create a new `MovidaEvents::Stats` object
@param last [Integer,nil] The last-processed event ID.
# File lib/movida_events/stats.rb, line 31 def initialize(last = nil) @last = last @requests = 0 @events = 0 @request_events = 0 end
Public Instance Methods
receive_event(event)
click to toggle source
Update stats when an event is received
@param event [Almodovar::Resource] The event received
# File lib/movida_events/stats.rb, line 41 def receive_event(event) @last = event.id @events += 1 @request_events += 1 end
start_request()
click to toggle source
Update stats when a new request is started
# File lib/movida_events/stats.rb, line 48 def start_request @requests += 1 @request_events = 0 end