class Periods::DateCalculator
Public Class Methods
new(date)
click to toggle source
# File lib/periods/date_calculator.rb, line 4 def initialize(date) @date = to_date(date) end
Public Instance Methods
beginning_of_month()
click to toggle source
# File lib/periods/date_calculator.rb, line 8 def beginning_of_month _, m, y = split to_date("#{1}.#{m}.#{y}") end
end_of_month()
click to toggle source
# File lib/periods/date_calculator.rb, line 13 def end_of_month self.class.new(@date.next_month).beginning_of_month.prev_day end
split()
click to toggle source
# File lib/periods/date_calculator.rb, line 17 def split @date.strftime('%d.%m.%Y').split('.') end
to_date(str)
click to toggle source
# File lib/periods/date_calculator.rb, line 21 def to_date(str) ::Date.parse(str.to_s) end