Class: Datadog::Tracing::Contrib::StatusRangeMatcher
- Inherits:
-
Object
- Object
- Datadog::Tracing::Contrib::StatusRangeMatcher
- Defined in:
- lib/datadog/tracing/contrib/status_range_matcher.rb
Overview
Useful checking whether the defined range covers status code
Instance Method Summary collapse
- #include?(status) ⇒ Boolean
-
#initialize(ranges) ⇒ StatusRangeMatcher
constructor
A new instance of StatusRangeMatcher.
Constructor Details
#initialize(ranges) ⇒ StatusRangeMatcher
Returns a new instance of StatusRangeMatcher.
8 9 10 |
# File 'lib/datadog/tracing/contrib/status_range_matcher.rb', line 8 def initialize(ranges) @ranges = Array(ranges) end |
Instance Method Details
#include?(status) ⇒ Boolean
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/datadog/tracing/contrib/status_range_matcher.rb', line 12 def include?(status) @ranges.any? do |e| case e when Range e.include? status when Integer e == status end end end |