Class: Redistat::Finder::DateSet

Inherits:
Array
  • Object
show all
Defined in:
lib/redistat/finder/date_set.rb

Instance Method Summary collapse

Constructor Details

#initialize(start_date = nil, end_date = nil, depth = nil, interval = false) ⇒ DateSet

Returns a new instance of DateSet.



5
6
7
8
9
# File 'lib/redistat/finder/date_set.rb', line 5

def initialize(start_date = nil, end_date = nil, depth = nil, interval = false)
  if !start_date.nil? && !end_date.nil?
    find_date_sets(start_date, end_date, depth, interval)
  end
end

Instance Method Details

#find_date_sets(start_date, end_date, depth = nil, interval = false) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/redistat/finder/date_set.rb', line 11

def find_date_sets(start_date, end_date, depth = nil, interval = false)
  if depth.nil? && interval.is_a?(Symbol)
    depth = interval
    interval = true
  end
  start_date = start_date.to_time if start_date.is_a?(::Date)
  end_date = end_date.to_time if end_date.is_a?(::Date)
  if !interval
    find_date_sets_by_magic(start_date, end_date, depth)
  else
    find_date_sets_by_interval(start_date, end_date, depth)
  end
end