Class: Dates::Saturday
- Inherits:
-
Object
- Object
- Dates::Saturday
- Defined in:
- lib/saturday/dates.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#month ⇒ Object
Returns the value of attribute month.
-
#year ⇒ Object
Returns the value of attribute year.
Instance Method Summary collapse
- #find_saturdays ⇒ Object
-
#initialize(year = nil, month = nil) ⇒ Saturday
constructor
A new instance of Saturday.
Constructor Details
#initialize(year = nil, month = nil) ⇒ Saturday
Returns a new instance of Saturday.
20 21 22 23 24 |
# File 'lib/saturday/dates.rb', line 20 def initialize(year=nil,month=nil) @year = year @month = month @date = @year && @month.nil? ? Date.new(year) : Date.new(year,month) end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
18 19 20 |
# File 'lib/saturday/dates.rb', line 18 def date @date end |
#month ⇒ Object
Returns the value of attribute month.
18 19 20 |
# File 'lib/saturday/dates.rb', line 18 def month @month end |
#year ⇒ Object
Returns the value of attribute year.
18 19 20 |
# File 'lib/saturday/dates.rb', line 18 def year @year end |
Instance Method Details
#find_saturdays ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/saturday/dates.rb', line 26 def find_saturdays @date.leap? ? MONTHS_MAP[:feb] = 29 : MONTHS_MAP dates = [] year ,month = @date.year ,@date.month if @year && @month MONTHS_MAP.each_with_index { |(key,value),index| dates << find_dates(year,month,value) if month == index} else MONTHS_MAP.each_with_index { |(key,value),index| dates << find_dates(year,month = index,value) unless index==0} end dates end |