Class: DateRange
- Inherits:
-
Object
- Object
- DateRange
- Defined in:
- lib/domain-finder/daterange.rb
Overview
Simple class for helping to parse string sets of dates and date ranges
Class Method Summary collapse
Class Method Details
.parse(text) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/domain-finder/daterange.rb', line 13 def self.parse text dates = text.gsub('-','/').split(',') dates.inject([]) do |all,this| if this.include?'..' range_dates = this.split('..') all + (Date.parse(range_dates.first)..Date.parse(range_dates.last)).to_a else all << Date.parse(this) end end end |