Module: Toller::Filters::Mutators::Time
- Defined in:
- lib/toller/filters/mutators/time.rb
Overview
Time filter mutator
Class Method Summary collapse
-
.call(value) ⇒ String, Range
Coerces a raw filter param into a time value or range.
-
.inclusive_or_exclusive_range(value) ⇒ String?
Detects whether
valuecontains inclusive or exclusive range syntax. -
.range(value, dots) ⇒ Range
Builds a Range by splitting
valueon the given range dots.
Class Method Details
.call(value) ⇒ String, Range
Coerces a raw filter param into a time value or range.
18 19 20 21 22 23 24 |
# File 'lib/toller/filters/mutators/time.rb', line 18 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) ⇒ String?
Detects whether value contains inclusive or exclusive range syntax.
42 43 44 45 46 47 |
# File 'lib/toller/filters/mutators/time.rb', line 42 def inclusive_or_exclusive_range(value) return "..." if value.include?("...") return ".." if value.include?("..") nil end |
.range(value, dots) ⇒ Range
Builds a Range by splitting value on the given range dots.
32 33 34 |
# File 'lib/toller/filters/mutators/time.rb', line 32 def range(value, dots) Range.new(*value.split(dots)) end |