Sha256: 24d39e1265401c4d4eed097ba4010fa49dc57f76c0330b946150c656f8a3d2b0

Contents?: true

Size: 707 Bytes

Versions: 3

Compression:

Stored size: 707 Bytes

Contents

module Roxbury
  # Wraps a specific date with its working hours schedule
  class BusinessDay
    def initialize date, working_hours
      @date = date
      @working_hours = working_hours
    end

    def number_of_working_hours *args
      @working_hours.quantity *args
    end

    def same_day? timestamp
      timestamp.to_date == @date.to_date
    end

    def include? timestamp
      same_day?(timestamp) && @working_hours.include?(timestamp)
    end

    def starts_after? timestamp
      same_day?(timestamp) && @working_hours.starts_after?(timestamp)
    end

    def at_beginning
      @working_hours.at_beginning @date
    end

    def at_end
      @working_hours.at_end @date
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
roxbury-0.2.1 lib/roxbury/business_day.rb
roxbury-0.1.1 lib/roxbury/business_day.rb
roxbury-0.1.0 lib/roxbury/business_day.rb