class TimeSpanner::TimeUnits::Month
Public Class Methods
new()
click to toggle source
Calls superclass method
TimeSpanner::TimeUnits::CalendarUnit::new
# File lib/time_spanner/time_units/month.rb, line 6 def initialize super 5 end
Private Instance Methods
at_amount(amount)
click to toggle source
# File lib/time_spanner/time_units/month.rb, line 18 def at_amount amount ( from.to_datetime >> amount ).to_time end
calculate_amount()
click to toggle source
# File lib/time_spanner/time_units/month.rb, line 13 def calculate_amount amount = ( to.year * 12 + to.month ) - ( from.year * 12 + from.month ) - ( to.day < from.day ? 1 : 0 ) @amount = at_amount( amount ) > to ? amount - 1 : amount end