Class: Necromancer::RangeConverters::StringToRangeConverter
- Defined in:
- lib/necromancer/converters/range.rb
Overview
An object that converts a String to a Range
Instance Attribute Summary
Attributes inherited from Converter
Instance Method Summary collapse
-
#call(value, options = {}) ⇒ Object
Convert value to Range type with possible ranges.
Methods inherited from Converter
create, #fail_conversion_type, #initialize
Constructor Details
This class inherits a constructor from Necromancer::Converter
Instance Method Details
#call(value, options = {}) ⇒ Object
Convert value to Range type with possible ranges
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/necromancer/converters/range.rb', line 28 def call(value, = {}) strict = .fetch(:strict, config.strict) case value when SINGLE_DIGIT_MATCHER ::Range.new($1.to_i, $1.to_i) when DIGIT_MATCHER ::Range.new($1.to_i, $3.to_i, $2 == '...') when LETTER_MATCHER ::Range.new($1.to_s, $3.to_s, $2 == '...') else strict ? fail_conversion_type(value) : value end end |