Sha256: 14dba4b20d93f1449853e328b1b679d5547318d08585401a514c855b47d3c17f
Contents?: true
Size: 976 Bytes
Versions: 7
Compression:
Stored size: 976 Bytes
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 def prepare # Convert the timestamp to the correct formats for quick timestamp comparisons @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 def filter(request) return nil unless 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
7 entries across 7 versions & 2 rubygems