Module: DateRanger

Defined in:
lib/date_ranger.rb,
lib/date_ranger/version.rb

Defined Under Namespace

Modules: Bootstrapper

Constant Summary collapse

VERSION =
"0.0.5"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#end_dateObject



26
27
28
29
30
31
32
33
# File 'lib/date_ranger.rb', line 26

def end_date
  @end_date ||= self.date_ranger_options[:default_end_date].call
  @end_date = @end_date.respond_to?(:to_date) ? @end_date.to_date : @end_date
  @end_date = case self.date_ranger_options[:timestep]
              when :daily; @end_date
              when :monthly; @end_date.end_of_month
              end
end

#start_dateObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/date_ranger.rb', line 13

def start_date
  @start_date ||= self.date_ranger_options[:default_start_date].call
  @start_date = if @start_date.respond_to?(:to_date)
                  @start_date.to_date
                else
                  @start_date
                end
  @start_date = case self.date_ranger_options[:timestep]
                when :daily; @start_date
                when :monthly; @start_date.beginning_of_month
                end
end

Instance Method Details

#date_ranger_optionsObject



5
6
7
8
9
10
11
# File 'lib/date_ranger.rb', line 5

def date_ranger_options
  if self.class.respond_to?(:date_ranger_options)
    self.class.date_ranger_options
  else
    super
  end
end