Sha256: 6ddd0253cfa0fa2607d853ac44f4dca3ef2df07e3b04584c1a2b5a8503cbfb4e
Contents?: true
Size: 1.19 KB
Versions: 2
Compression:
Stored size: 1.19 KB
Contents
module RequestLogAnalyzer::Filter # Reject all requests not in given timespan # Options # * <tt>:after</tt> Only keep requests after this DateTime. # * <tt>:before</tt> Only keep requests before this DateTime. class Timespan < Base attr_reader :before, :after # Convert the timestamp to the correct formats for quick timestamp comparisons. # These are stored in the before and after attr_reader fields. def prepare @after = @options[:after].strftime('%Y%m%d%H%M%S').to_i if options[:after] @before = @options[:before].strftime('%Y%m%d%H%M%S').to_i if options[:before] end # Returns request if: # * @after <= request.timestamp <= @before # * @after <= request.timestamp # * request.timestamp <= @before # Returns nil otherwise # <tt>request</tt> Request object. def filter(request) if @after && @before && request.timestamp <= @before && @after <= request.timestamp return request elsif @after && @before.nil? && @after <= request.timestamp return request elsif @before && @after.nil? && request.timestamp <= @before return request end return nil end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
wvanbergen-request-log-analyzer-1.1.2 | lib/request_log_analyzer/filter/timespan.rb |
request-log-analyzer-1.1.2 | lib/request_log_analyzer/filter/timespan.rb |