Module: Toller::Filters::Mutators::Date

Defined in:
lib/toller/filters/mutators/date.rb

Overview

Date filter mutator

Class Method Summary collapse

Class Method Details

.call(value) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/toller/filters/mutators/date.rb', line 12

def call(value)
  range_dots = inclusive_or_exclusive_range(value)

  return value if range_dots.blank?

  range(value, range_dots)
end

.inclusive_or_exclusive_range(value) ⇒ Object



24
25
26
27
28
29
# File 'lib/toller/filters/mutators/date.rb', line 24

def inclusive_or_exclusive_range(value)
  return '...' if value.include?('...')
  return '..' if value.include?('..')

  nil
end

.range(value, dots) ⇒ Object



20
21
22
# File 'lib/toller/filters/mutators/date.rb', line 20

def range(value, dots)
  Range.new(*value.split(dots))
end