Sha256: 41793ea91fe69f36d7948879ba194428d192853909ddbf3954541a0588ffd0aa
Contents?: true
Size: 1.31 KB
Versions: 41
Compression:
Stored size: 1.31 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 def initialize(file_format, options = {}) super(file_format, options) setup_filter end # Convert the timestamp to the correct formats for quick timestamp comparisons. # These are stored in the before and after attr_reader fields. def setup_filter @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
41 entries across 41 versions & 2 rubygems
Version | Path |
---|---|
request-log-analyzer-1.1.5.1 | lib/request_log_analyzer/filter/timespan.rb |