Sha256: 9b29423eae7d4d1589adf0ecf44375e18c508c0965273261b7f05228c106e654

Contents?: true

Size: 736 Bytes

Versions: 1

Compression:

Stored size: 736 Bytes

Contents

# frozen_string_literal: true
require_relative './support/unit'

module TimeBoss
  class Calendar
    class Day < Support::Unit
      def initialize(calendar, start_date)
        super(calendar, start_date, start_date)
      end

      def name
        start_date.to_s
      end

      def title
        start_date.strftime('%B %-d, %Y')
      end

      def to_s
        name
      end

      def index
        @_index ||= (start_date - year.start_date).to_i + 1
      end

      def year_index
        @_year_index ||= year.year_index
      end

      private

      def down
        self.class.new(calendar, start_date - 1.day)
      end

      def up
        self.class.new(calendar, start_date + 1.day)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
timeboss-0.0.10 lib/timeboss/calendar/day.rb