Class: Clive::Type::Range
- Inherits:
-
Object
- Object
- Clive::Type
- Object
- Clive::Type::Range
- Defined in:
- lib/clive/type/definitions.rb
Overview
Range accepts ‘a..b’, ‘a…b’ which behave as in ruby and ‘a-b’ which behaves like ‘a..b’. It returns the correct Range object.
Instance Method Summary collapse
Methods inherited from Object
Methods inherited from Clive::Type
cast, find_class, match, refute, typecast, #valid?, valid?
Instance Method Details
#typecast(arg) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/clive/type/definitions.rb', line 114 def typecast(arg) if arg.include?('...') a,b = arg.split('...') ::Range.new a, b, true elsif arg.include?('..') a,b = arg.split('..') ::Range.new a, b, false else a,b = arg.split('-') ::Range.new a, b, false end end |