Class: Biz::Day

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Comparable
Defined in:
lib/biz/day.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(day) ⇒ Day



30
31
32
# File 'lib/biz/day.rb', line 30

def initialize(day)
  @day = Integer(day)
end

Instance Attribute Details

#dayObject (readonly)

Returns the value of attribute day.



22
23
24
# File 'lib/biz/day.rb', line 22

def day
  @day
end

Class Method Details

.from_date(date) ⇒ Object



8
9
10
# File 'lib/biz/day.rb', line 8

def self.from_date(date)
  new((date - Date::EPOCH).to_i)
end

.from_time(time) ⇒ Object Also known as: since_epoch



12
13
14
# File 'lib/biz/day.rb', line 12

def self.from_time(time)
  from_date(time.to_date)
end

Instance Method Details

#coerce(other) ⇒ Object



38
39
40
# File 'lib/biz/day.rb', line 38

def coerce(other)
  [self.class.new(other), self]
end

#to_dateObject



34
35
36
# File 'lib/biz/day.rb', line 34

def to_date
  Date.from_day(day)
end