Class: MoonDate
- Inherits:
-
Date
- Object
- Date
- MoonDate
- Defined in:
- lib/moon_date.rb
Constant Summary collapse
- DAY_NAME =
["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
- MONTH_NAME =
["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
Instance Method Summary collapse
- #current_week ⇒ Object
- #day_name ⇒ Object
- #month_days(padded = false) ⇒ Object
- #month_name ⇒ Object
- #moon_phase ⇒ Object
- #week_days(padded = false) ⇒ Object
Instance Method Details
#current_week ⇒ Object
14 15 16 |
# File 'lib/moon_date.rb', line 14 def current_week naive_cweek(self) - naive_cweek(MoonDate.new(self.year, self.month, 1)) + 1 end |
#day_name ⇒ Object
18 19 20 |
# File 'lib/moon_date.rb', line 18 def day_name DAY_NAME[self.cwday - 1] end |
#month_days(padded = false) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/moon_date.rb', line 26 def month_days(padded=false) days = (0..31).filter { |day| Date.valid_date?(self.year, self.month, day) }.map do |day| MoonDate.new(self.year, self.month, day) end padded ? pad_days(days) : days end |
#month_name ⇒ Object
22 23 24 |
# File 'lib/moon_date.rb', line 22 def month_name MONTH_NAME[self.month - 1] end |
#moon_phase ⇒ Object
34 35 36 |
# File 'lib/moon_date.rb', line 34 def moon_phase MoonCalc.new(self).phase end |
#week_days(padded = false) ⇒ Object
9 10 11 12 |
# File 'lib/moon_date.rb', line 9 def week_days(padded=false) week_days = month_days.filter { |day| day.cweek == self.cweek } padded ? pad_days(week_days) : week_days end |