Class: SelectRailsLog::Filter::DurationRangeFilter

Inherits:
BaseFilter show all
Includes:
RangePattern
Defined in:
lib/select_rails_log/filter/duration_range_filter.rb

Constant Summary

Constants included from Constants

Constants::ACTION, Constants::CLIENT, Constants::COMPLETED, Constants::CONTROLLER, Constants::DEBUG, Constants::DEFAULT_OUTPUT, Constants::DURATION, Constants::HTTP_METHOD, Constants::HTTP_STATUS, Constants::ID, Constants::INTERVAL, Constants::LOGS, Constants::MESSAGE, Constants::PARAMETERS, Constants::PATH, Constants::PERFORMANCE, Constants::PERFORMANCE_ACTIVE_RECORD, Constants::PERFORMANCE_ALLOCATIONS, Constants::PERFORMANCE_VIEWS, Constants::PID, Constants::RAW_LOGS, Constants::REQUEST_ID, Constants::SEVERITY, Constants::STARTED, Constants::TIME

Instance Attribute Summary

Attributes inherited from Extension

#options

Instance Method Summary collapse

Methods inherited from BaseFilter

filter_type, #line_filter?, #request_filter?

Methods inherited from Extension

option_initializers

Constructor Details

#initializeDurationRangeFilter

Returns a new instance of DurationRangeFilter.



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/select_rails_log/filter/duration_range_filter.rb', line 18

def initialize(...)
  super

  pattern = options[:pattern]
  return unless pattern

  begin
    @range = parse_range_pattern(pattern, &:to_i)
  rescue ArgumentError
    raise CommandLineOptionError, "invalid duration range pattern `#{pattern}`"
  end
end

Instance Method Details

#run(data) ⇒ Object



35
36
37
# File 'lib/select_rails_log/filter/duration_range_filter.rb', line 35

def run(data)
  @range.cover?(data[DURATION])
end

#runnable?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/select_rails_log/filter/duration_range_filter.rb', line 31

def runnable?
  !!@range
end