Class: Calendario::Year
- Inherits:
-
Object
- Object
- Calendario::Year
- Defined in:
- lib/calendario/year.rb
Overview
A period of 365 or 366 days, in the Gregorian calendar, divided into 12 calendar months
Instance Attribute Summary collapse
-
#months ⇒ Array<Month>
readonly
private
Array of all calendar months.
-
#year_number ⇒ Integer
readonly
private
The primitive numeric representation of a year.
Instance Method Summary collapse
-
#days ⇒ Date
private
An array of 365 or 365 dates representing every day of the year.
-
#first_day ⇒ Date
private
The first day of the year (1st of January).
-
#initialize(year_number = 2020) ⇒ Year
constructor
private
Initialize a year.
-
#last_day ⇒ Date
private
The last day of the year (31st of December).
Constructor Details
#initialize(year_number = 2020) ⇒ Year
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize a year
26 27 28 29 30 31 |
# File 'lib/calendario/year.rb', line 26 def initialize(year_number = 2020) @year_number = year_number @months = 1.upto(12).map do |month_number| Month.new(year_number, month_number) end end |
Instance Attribute Details
#months ⇒ Array<Month> (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Array of all calendar months
12 13 14 |
# File 'lib/calendario/year.rb', line 12 def months @months end |
#year_number ⇒ Integer (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The primitive numeric representation of a year
19 20 21 |
# File 'lib/calendario/year.rb', line 19 def year_number @year_number end |
Instance Method Details
#days ⇒ Date
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
An array of 365 or 365 dates representing every day of the year
56 57 58 |
# File 'lib/calendario/year.rb', line 56 def days @days ||= months.map(&:days).flatten end |
#first_day ⇒ Date
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The first day of the year (1st of January)
38 39 40 |
# File 'lib/calendario/year.rb', line 38 def first_day @first_day ||= months.first.first_day end |
#last_day ⇒ Date
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The last day of the year (31st of December)
47 48 49 |
# File 'lib/calendario/year.rb', line 47 def last_day @last_day ||= months.last.last_day end |