Class: TimeBoots::MonthBoot

Inherits:
Boot
  • Object
show all
Defined in:
lib/time_boots/boot/month.rb

Constant Summary

Constants included from TimeBoots

VERSION

Instance Attribute Summary

Attributes inherited from Boot

#step

Instance Method Summary collapse

Methods inherited from Boot

#advance, #ceil, #decrease, #floor, get, #jump, #lace, #measure_rem, #range, #range_back, #round, #round?, steps

Methods included from TimeBoots

#advance, #ceil, #day, #decrease, #floor, #hour, #jump, #lace, #min, #month, #range, #range_back, #round, #round?, #sec, #steps, #week, #year

Constructor Details

#initializeMonthBoot

Returns a new instance of MonthBoot.



4
5
6
# File 'lib/time_boots/boot/month.rb', line 4

def initialize
  super(:month)
end

Instance Method Details

#measure(from, to) ⇒ Object



8
9
10
11
12
13
# File 'lib/time_boots/boot/month.rb', line 8

def measure(from, to)
  ydiff = to.year - from.year
  mdiff = to.month - from.month

  to.day >= from.day ? (ydiff * 12 + mdiff) : (ydiff * 12 + mdiff - 1)
end