class Shellout::Calendar

Public Class Methods

new(date=Date.today) click to toggle source
# File lib/shellout/calendar.rb, line 6
def initialize(date=Date.today)
  @date = date
  @list_of_days = "Mo Tu We Th Fr Sa Su"
end

Public Instance Methods

print(out=$stdout) click to toggle source
print3(out=$stdout) click to toggle source
# File lib/shellout/calendar.rb, line 15
def print3(out=$stdout)
  print_helper(out, [@date.prev_month, @date, @date.next_month])
end

Private Instance Methods

ansi_reverse_color(s) click to toggle source
# File lib/shellout/calendar.rb, line 120
def ansi_reverse_color(s); "\e[7m#{s}\e[0m"; end
days(for_date) click to toggle source
# File lib/shellout/calendar.rb, line 98
def days(for_date)
  days = (1..last_day_of_month(for_date).day).to_a
  unshift_empty_strings_for_missing_week(days, for_date)
end
first_day_of_month(date) click to toggle source
# File lib/shellout/calendar.rb, line 112
def first_day_of_month(date)
  Date.new(date.year, date.month)
end
is_current_month?(date) click to toggle source
# File lib/shellout/calendar.rb, line 90
def is_current_month?(date)
  Date.today.month == date.month
end
is_current_year?(date) click to toggle source
# File lib/shellout/calendar.rb, line 94
def is_current_year?(date)
  Date.today.year == date.year
end
last_day_of_month(date) click to toggle source
# File lib/shellout/calendar.rb, line 116
def last_day_of_month(date)
  first_day_of_month(date).next_month-1
end
print_days(out, dates) click to toggle source
print_heading_months(out, dates) click to toggle source
print_heading_name_of_days(out, dates) click to toggle source
print_heading_year(out, dates) click to toggle source
print_headings(out, dates) click to toggle source
print_helper(out, dates) click to toggle source
print_year_on_a_separate_line?(dates) click to toggle source
push_empty_strings_for_missing_week_days(week) click to toggle source
# File lib/shellout/calendar.rb, line 108
def push_empty_strings_for_missing_week_days(week)
  week + Array.new(7 - week.length, "")
end
unshift_empty_strings_for_missing_week(days, date) click to toggle source
# File lib/shellout/calendar.rb, line 103
def unshift_empty_strings_for_missing_week(days, date)
  wday = (first_day_of_month(date).wday - 1) % 7
  Array.new(wday, "") + days
end