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