Class: CodelessCode::Filters::Date

Inherits:
Object
  • Object
show all
Defined in:
lib/codeless_code/filters/date.rb

Defined Under Namespace

Classes: Matcher

Instance Method Summary collapse

Constructor Details

#initialize(exact: nil, min: nil, max: nil, exclude: false) ⇒ Date

Returns a new instance of Date.



21
22
23
24
25
26
# File 'lib/codeless_code/filters/date.rb', line 21

def initialize(exact: nil, min: nil, max: nil, exclude: false)
  @exact = exact
  @min = min
  @max = max
  @exclude = exclude
end

Instance Method Details

#call(fable) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/codeless_code/filters/date.rb', line 32

def call(fable)
  if (val = fable.date)
    return false unless @exact.nil? || @exact == val
    return false unless @min.nil? || @min <= val
    return false unless @max.nil? || @max >= val
    true
  else
    @exclude
  end
end

#enabled?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/codeless_code/filters/date.rb', line 28

def enabled?
  @exact || @min || @max || @exclude
end