class SpaceTime

Public Class Methods

for_current_month() click to toggle source
# File lib/spacetime.rb, line 26
def self.for_current_month
  for_month
end
for_day(date=Date.today) click to toggle source
# File lib/spacetime.rb, line 16
def self.for_day(date=Date.today)
  new(date.midnight, date.tomorrow.midnight)
end
for_month(date = Date.today) click to toggle source
# File lib/spacetime.rb, line 22
def self.for_month(date = Date.today)
  date = date.to_date
  new(date.beginning_of_month.midnight, date.at_end_of_month.tomorrow.midnight)
end
for_week(date = Date.today) click to toggle source
# File lib/spacetime.rb, line 19
def self.for_week(date = Date.today)
  new(date.beginning_of_week.midnight, date.end_of_week.tomorrow.midnight)
end
new(start_time, end_time) click to toggle source
# File lib/spacetime.rb, line 5
def initialize(start_time, end_time)
  @start_time = start_time
  @end_time = end_time

  if @start_time > @end_time
    temp = @end_time
    @end_time = @start_time
    @start_time = temp
  end
end
recent_days_upto_datetime_or_now(datetime, num_days) click to toggle source
# File lib/spacetime.rb, line 29
def self.recent_days_upto_datetime_or_now(datetime, num_days)
  datetime_for_end = [Time.now, datetime].min
  new(datetime_for_end - num_days.days, datetime_for_end)
end

Public Instance Methods

cover?(time) click to toggle source
# File lib/spacetime.rb, line 43
def cover?(time)
  (@start_time..@end_time).cover?(time)
end
end() click to toggle source
# File lib/spacetime.rb, line 39
def end
  @end_time
end
start() click to toggle source

Instance methods

# File lib/spacetime.rb, line 35
def start
  @start_time
end