class Balboa::PunchDate

Public Class Methods

new(date, cli) click to toggle source
# File lib/balboa/punch_date.rb, line 7
def initialize(date, cli)
  @date = date
  @cli = cli
  @holiday = Hash(Holidays.on(date, :br).first)
end

Public Instance Methods

punchable?() click to toggle source
# File lib/balboa/punch_date.rb, line 13
def punchable?
  if weekend?
    false
  elsif holiday?
    ask_for_punch
  else
    true
  end
end
strftime(format) click to toggle source
# File lib/balboa/punch_date.rb, line 27
def strftime(format)
  @date.strftime(format)
end
to_date() click to toggle source
# File lib/balboa/punch_date.rb, line 31
def to_date
  @date
end
to_s() click to toggle source
# File lib/balboa/punch_date.rb, line 23
def to_s
  @date.to_s
end

Private Instance Methods

ask_for_punch() click to toggle source
# File lib/balboa/punch_date.rb, line 37
def ask_for_punch
  @cli.agree(" #{holiday_name}. Punch? (y|n) ")
end
holiday?() click to toggle source
# File lib/balboa/punch_date.rb, line 45
def holiday?
  !@holiday.empty?
end
holiday_name() click to toggle source
# File lib/balboa/punch_date.rb, line 41
def holiday_name
  @holiday[:name]
end
weekend?() click to toggle source
# File lib/balboa/punch_date.rb, line 49
def weekend?
  @date.sunday? || @date.saturday?
end