Sha256: fae4319ca8ebe8270e0d88b7b8d2d4c9f0415f2f9489e46389766b6594e8c730

Contents?: true

Size: 816 Bytes

Versions: 3

Compression:

Stored size: 816 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 ends_before? timestamp
      same_day?(timestamp) && @working_hours.ends_before?(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.3.0 lib/roxbury/business_day.rb
roxbury-0.2.3 lib/roxbury/business_day.rb
roxbury-0.2.2 lib/roxbury/business_day.rb