I have some Ruby code which takes dates on the command line in the format:
-d 20080101,20080201..20080229,20080301
I want to run for all da
Inject with no args works well for two element arrays:
rng='20080201..20080229'.split('..').inject { |s,e| s.to_i..e.to_i }
Of course, this can be made generic
class Range
def self.from_ary(a)
a.inject{|s,e| s..e }
end
end
rng = Range.from_ary('20080201..20080229'.split('..').map{|s| s.to_i})
rng.class # => Range