Class: Temporal::Units::Year

Inherits:
Base
  • Object
show all
Defined in:
lib/temporal/units/year.rb

Instance Method Summary collapse

Methods inherited from Base

#<=>, #==, #initialize, #inspect, #to_f, #to_i, #to_s

Constructor Details

This class inherits a constructor from Temporal::Units::Base

Instance Method Details

#+(other, inplace: true) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/temporal/units/year.rb', line 7

def +(other, inplace: true)
  result = @value + other

  @value = result if inplace

  self.class.new(result)
end

#-(other, inplace: true) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/temporal/units/year.rb', line 15

def -(other, inplace: true)
  result = @value - other

  @value = result if inplace

  self.class.new(result)
end

#leap?Boolean

Returns:

  • (Boolean)


5
# File 'lib/temporal/units/year.rb', line 5

def leap? = (@value % 4).zero?