Class: QueryFilter::Rules::SplitterRange::RangeParam
- Inherits:
-
Object
- Object
- QueryFilter::Rules::SplitterRange::RangeParam
- Defined in:
- lib/query_filter/rules/splitter_range.rb
Constant Summary collapse
- SPLITTER =
/[;-]/.freeze
Instance Method Summary collapse
-
#initialize(value) ⇒ RangeParam
constructor
A new instance of RangeParam.
- #items ⇒ Object
- #range ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(value) ⇒ RangeParam
Returns a new instance of RangeParam.
9 10 11 |
# File 'lib/query_filter/rules/splitter_range.rb', line 9 def initialize(value) @value = value end |
Instance Method Details
#items ⇒ Object
21 22 23 |
# File 'lib/query_filter/rules/splitter_range.rb', line 21 def items @items ||= @value.split(SPLITTER).map(&:strip).map(&:to_i) end |
#range ⇒ Object
17 18 19 |
# File 'lib/query_filter/rules/splitter_range.rb', line 17 def range ::Range.new(*items) end |
#valid? ⇒ Boolean
13 14 15 |
# File 'lib/query_filter/rules/splitter_range.rb', line 13 def valid? @value.present? && items.size == 2 end |