Class: Date

Inherits:
Object
  • Object
show all
Includes:
Cubicle::DateTime
Defined in:
lib/cubicle/support.rb

Instance Method Summary collapse

Methods included from Cubicle::DateTime

#beginning_of, db_time_format, db_time_format=, #iso8601?, iso8601?, #to_cubicle

Instance Method Details

#step_byObject

iteration



31
32
33
# File 'lib/cubicle/support.rb', line 31

def step_by
  @step_by ||= :day
end

#step_by=(by) ⇒ Object



35
36
37
# File 'lib/cubicle/support.rb', line 35

def step_by=(by)
  @step_by = by
end

#succObject



39
40
41
42
43
44
45
46
47
48
# File 'lib/cubicle/support.rb', line 39

def succ
  step_by = :day if step_by.to_sym == :date
  valid_steps = [:second,:minute,:hour,:week,:days,:month,:year]
  valid_steps += valid_steps.map{|s|s.to_s.pluralize.to_sym}
  raise "Invalid 'step_by' speficication. Was #{step_by} but must be one of #{valid_steps.inspect}" unless valid_steps.include?(step_by.to_sym)

  next_date = advance(step_by.to_s.pluralize.to_sym=>1)
  next_date.step_by = self.step_by
  next_date
end