Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/to_range/string.rb
Instance Method Summary collapse
Instance Method Details
#to_range ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/to_range/string.rb', line 5 def to_range str = scan(/\d+\.{2,3}\d+/).first dots = str.count('.') if dots > 3 raise ToRangeParseFailed end three_dots = (dots == 3) arr = three_dots ? str.split('...') : str.split('..') first = arr.first.to_i last = arr.last.to_i three_dots ? first...last : first..last end |