class EasterVoice

Public Class Methods

new(future: false) click to toggle source
# File lib/easter.rb, line 106
def initialize(future: false)
  @future = future
end

Public Instance Methods

ascension_day() click to toggle source
# File lib/easter.rb, line 111
def ascension_day() date :ascension_day, 'Ascension day' end
ash_wednesday() click to toggle source
# File lib/easter.rb, line 112
def ash_wednesday() date :ash_wednesday, 'Ash Wednesday' end
easter() click to toggle source
# File lib/easter.rb, line 110
def easter()        date :easter                         end
easter_dates() click to toggle source
# File lib/easter.rb, line 119
def easter_dates()
  %i(ash_wednesday palm_sunday good_friday easter ascension_day  pentecost)\
      .map {|day| method(day).call }.join("\n")
end
good_friday() click to toggle source
# File lib/easter.rb, line 113
def good_friday()   date :good_friday,   'Good Friday'   end
holy_saturday() click to toggle source
# File lib/easter.rb, line 115
def holy_saturday() date :holy_saturday, 'Holy Saturday' end
holy_thursday() click to toggle source
# File lib/easter.rb, line 114
def holy_thursday() date :holy_thursday, 'Holy Thursday' end
lent() click to toggle source
# File lib/easter.rb, line 128
def lent()
  
  participle = case Date.today
  when (Easter.ash_wednesday..Easter.holy_thursday) then 'is'      
  when (Date.new(Date.year)..Easter.ash_wednesday) then 'will be'
  else 
    'was'
  end
  
  days =  %i(ash_wednesday holy_thursday)\
      .map {|x| Easter.method(x).call.humanize(year: true).sub(/on /,'') }
  "Lent %s from %s to %s." % [participle, *days]
end
lent_end() click to toggle source
# File lib/easter.rb, line 126
def lent_end()   date :holy_thursday, 'The end of Lent'    end
lent_start() click to toggle source
# File lib/easter.rb, line 125
def lent_start() date :ash_wednesday, 'Lent'               end
palm_sunday() click to toggle source
# File lib/easter.rb, line 116
def palm_sunday()   date :palm_sunday,   'Palm Sunday'   end
pentecost() click to toggle source
# File lib/easter.rb, line 117
def pentecost()     date :pentecost,     'Pentecost'     end

Private Instance Methods

date(s, label=s.to_s.capitalize) click to toggle source
# File lib/easter.rb, line 144
def date(s, label=s.to_s.capitalize)

  d = Easter.method(s.to_sym).call    
  
  year = if d < Date.today and @future then
    d = Easter.method(s.to_sym).call(Time.now.year+1)
    ' ' + (Time.now.year+1).to_s
  else
    ''
  end
  
  participle = d >= Date.today ? 'is' : 'was'
  r = "%s %s %s" % [label, participle, d.humanize]
  r + year + '.'
end