Class: Suprdate::Year
- Inherits:
-
Unit
- Object
- Unit
- Suprdate::Year
show all
- Defined in:
- lib/suprdate/year.rb
Constant Summary
collapse
- MINIMUM_VALUE =
year when leap years were first standardized
1582
- STRFTIME_STR =
'%Y'
Instance Attribute Summary collapse
Attributes inherited from Unit
#value
Instance Method Summary
collapse
Methods inherited from Unit
<=>, #==, #hash, #new, significance, #to_s
#name_plural, #name_singular, #to_sym
Instance Attribute Details
#day_factory ⇒ Object
Returns the value of attribute day_factory.
5
6
7
|
# File 'lib/suprdate/year.rb', line 5
def day_factory
@day_factory
end
|
#month_factory ⇒ Object
Returns the value of attribute month_factory.
5
6
7
|
# File 'lib/suprdate/year.rb', line 5
def month_factory
@month_factory
end
|
#week_definition ⇒ Object
Returns the value of attribute week_definition.
5
6
7
|
# File 'lib/suprdate/year.rb', line 5
def week_definition
@week_definition
end
|
#week_factory ⇒ Object
Returns the value of attribute week_factory.
5
6
7
|
# File 'lib/suprdate/year.rb', line 5
def week_factory
@week_factory
end
|
Instance Method Details
#+(increase) ⇒ Object
32
|
# File 'lib/suprdate/year.rb', line 32
def +(increase) new(@value + increase) end
|
#-(decrease) ⇒ Object
33
|
# File 'lib/suprdate/year.rb', line 33
def -(decrease) new(@value - decrease) end
|
#<=>(operand) ⇒ Object
21
22
23
24
25
|
# File 'lib/suprdate/year.rb', line 21
def <=>(operand)
return -1 if operand == Infinity
operand = operand.year
@value - operand.value
end
|
#day(*args) ⇒ Object
37
|
# File 'lib/suprdate/year.rb', line 37
def day(*args) month(1).day(*args) end
|
#days ⇒ Object
36
|
# File 'lib/suprdate/year.rb', line 36
def days() months.map { |m| m.days }.flatten end
|
#inspect ⇒ Object
38
|
# File 'lib/suprdate/year.rb', line 38
def inspect() @value.to_s end
|
#leap? ⇒ Boolean
43
44
45
46
47
48
|
# File 'lib/suprdate/year.rb', line 43
def leap?
return true if @value % 400 == 0
return false if @value % 100 == 0
return true if @value % 4 == 0
false
end
|
#month(*indices) ⇒ Object
Also known as:
[]
27
28
29
30
|
# File 'lib/suprdate/year.rb', line 27
def month(*indices)
indices = [1] if indices.empty?
Utility::disarray(indices.map { |i| new_month(i) })
end
|
#months ⇒ Object
35
|
# File 'lib/suprdate/year.rb', line 35
def months() MONTH_RANGE.to_a.map { |i| new_month(i) } end
|
#since(year) ⇒ Object
40
|
# File 'lib/suprdate/year.rb', line 40
def since(year) @value - year.value end
|
#succ ⇒ Object
34
|
# File 'lib/suprdate/year.rb', line 34
def succ() self + 1 end
|
#until(year) ⇒ Object
41
|
# File 'lib/suprdate/year.rb', line 41
def until(year) year.value - @value end
|
#year ⇒ Object
39
|
# File 'lib/suprdate/year.rb', line 39
def year() self end
|