class ImportantDate

Public Instance Methods

date_string(format=:long) click to toggle source
# File lib/buweb/important_date.rb, line 47
def date_string(format=:long)
  formatter = (format == :short) ? '%b' : '%B'
  if end_date
    if start_date.month == end_date.month
      start_date.strftime("#{formatter} %-d") + " - " + end_date.strftime("%-d")
    else
      start_date.strftime("#{formatter} %-d") + " - " + end_date.strftime("#{formatter} %-d")
    end
  else
    start_date.strftime("#{formatter} %-d")
  end
end
days_of_week(format=:long) click to toggle source
# File lib/buweb/important_date.rb, line 41
def days_of_week(format=:long)
  formatter = (format == :short) ? '%a' : '%A'
  start_date.strftime(formatter) +
  (end_date ? " - #{end_date.strftime(formatter)}" : "")
end
to_s() click to toggle source
# File lib/buweb/important_date.rb, line 37
def to_s
  title
end

Private Instance Methods

end_date_after_start_date() click to toggle source
# File lib/buweb/important_date.rb, line 82
def end_date_after_start_date
  errors.add :end_date, 'must be after start date' if end_date && end_date <= start_date
end