Sha256: c95c8a095a14b2b5448c206060b5ad2bec695046ea57500f90c341f57dbf2033
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true require_relative '../../punch_date' module Balboa module CLI module Command class PunchCommand def initialize(interactor, cli) @interactor = interactor @cli = cli end def execute punch_dates.reject! { |date| skip_date?(date) } punch_dates.each { |date| @interactor.punch(date) } command_output end private def punch_dates @punch_dates ||= (last_punch_date..(Date.today - 1)).map do |date| Balboa::PunchDate.new(date, @cli) end end def command_output punch_dates.map do |date| "\n#{date.strftime('%d/%m/%Y')}" end.join end def skip_date?(punch_date) !punch_date.punchable? || skips_include?(punch_date) end def skips_include?(punch_date) skipped_dates.include?(punch_date.to_date) end def skipped_dates @interactor.options['skips'] end def last_punch_date Date.parse(@interactor.last) + 1 end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
balboa-0.1.7 | lib/balboa/cli/command/punch_command.rb |