Module: Toller::Filters::Mutators::Integer
- Defined in:
- lib/toller/filters/mutators/integer.rb
Overview
Integer filter mutator
Class Method Summary collapse
- .call(value) ⇒ Object
- .inclusive_or_exclusive_range(value) ⇒ Object
- .range(value) ⇒ Object
- .range?(value) ⇒ Boolean
Class Method Details
.call(value) ⇒ Object
12 13 14 15 16 |
# File 'lib/toller/filters/mutators/integer.rb', line 12 def call(value) return value unless range?(value) range(value) end |
.inclusive_or_exclusive_range(value) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/toller/filters/mutators/integer.rb', line 28 def inclusive_or_exclusive_range(value) return '...' if value.include?('...') return '..' if value.include?('..') nil end |
.range(value) ⇒ Object
24 25 26 |
# File 'lib/toller/filters/mutators/integer.rb', line 24 def range(value) Range.new(*value.split(inclusive_or_exclusive_range(value))) end |
.range?(value) ⇒ Boolean
18 19 20 21 22 |
# File 'lib/toller/filters/mutators/integer.rb', line 18 def range?(value) range_dots = inclusive_or_exclusive_range(value) range_dots.present? end |