Class: Daru::Offsets::Tick Abstract

Inherits:
DateOffset show all
Defined in:
lib/daru/date_time/offsets.rb

Overview

This class is abstract.

Private superclass for Offsets with equal inter-frequencies.

Direct Known Subclasses

Day, Hour, Minute, Month, Second, Year

Instance Method Summary collapse

Constructor Details

#initialize(n = 1) ⇒ Tick

Initialize one of the subclasses of Tick with the number of the times the offset should be applied, which is the supplied as the argument.

Parameters:

  • n (Integer) (defaults to: 1)

    The number of times an offset should be applied.



84
85
86
# File 'lib/daru/date_time/offsets.rb', line 84

def initialize n=1
  @n = n
end

Instance Method Details

#+(date_time) ⇒ Object



88
89
90
# File 'lib/daru/date_time/offsets.rb', line 88

def + date_time
  date_time + @n*multiplier
end

#-(date_time) ⇒ Object



92
93
94
# File 'lib/daru/date_time/offsets.rb', line 92

def - date_time
  date_time - @n*multiplier
end