Class: CodelessCode::Filters::HeaderInteger
- Inherits:
-
Object
- Object
- CodelessCode::Filters::HeaderInteger
- Defined in:
- lib/codeless_code/filters/header_integer.rb
Instance Method Summary collapse
- #call(fable) ⇒ Object
- #enabled? ⇒ Boolean
-
#initialize(key, exact: nil, min: nil, max: nil, exclude: false) ⇒ HeaderInteger
constructor
A new instance of HeaderInteger.
Constructor Details
#initialize(key, exact: nil, min: nil, max: nil, exclude: false) ⇒ HeaderInteger
Returns a new instance of HeaderInteger.
19 20 21 22 23 24 25 |
# File 'lib/codeless_code/filters/header_integer.rb', line 19 def initialize(key, exact: nil, min: nil, max: nil, exclude: false) @key = key @exact = exact @min = min @max = max @exclude = exclude end |
Instance Method Details
#call(fable) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/codeless_code/filters/header_integer.rb', line 31 def call(fable) if fable.header?(@key) && (val = fable[@key]&.to_i) return false unless @exact.nil? || val == @exact return false unless @min.nil? || val >= @min.to_i return false unless @max.nil? || val <= @max.to_i true else @exclude end end |
#enabled? ⇒ Boolean
27 28 29 |
# File 'lib/codeless_code/filters/header_integer.rb', line 27 def enabled? @exact || @min || @max || @exclude end |