Sha256: 6d502c9f186819282508d12a9db400fffa2994bf47b88d61275a0731486e8c5b
Contents?: true
Size: 720 Bytes
Versions: 3
Compression:
Stored size: 720 Bytes
Contents
# frozen_string_literal: true require 'holidays' module Balboa class PunchDate def initialize(date, cli) @date = date @cli = cli @holiday = Hash(Holidays.on(date, :br).first) end def punchable? if weekend? false elsif holiday? ask_for_punch else true end end def to_s @date.to_s end def strftime(format) @date.strftime(format) end private def ask_for_punch @cli.agree(" #{holiday_name}. Punch? (y|n) ") end def holiday_name @holiday[:name] end def holiday? !@holiday.empty? end def weekend? @date.sunday? || @date.saturday? end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
balboa-0.1.6 | lib/balboa/punch_date.rb |
balboa-0.1.5 | lib/balboa/punch_date.rb |
balboa-0.1.4 | lib/balboa/punch_date.rb |