Class: Cal::Day

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/cal/day.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(date, calendar) ⇒ Day

Returns a new instance of Day.



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

def initialize(date, calendar)
  @date = date
  @calendar = calendar
end

Instance Attribute Details

#calendarObject (readonly)

Returns the value of attribute calendar.



13
14
15
# File 'lib/cal/day.rb', line 13

def calendar
  @calendar
end

#dateObject (readonly)

Returns the value of attribute date.



13
14
15
# File 'lib/cal/day.rb', line 13

def date
  @date
end

Instance Method Details

#<=>(other) ⇒ Object



21
22
23
# File 'lib/cal/day.rb', line 21

def <=>(other)
  date <=> other.date
end

#==(other) ⇒ Object



17
18
19
# File 'lib/cal/day.rb', line 17

def ==(other)
  other.is_a?(Day) && calendar == other.calendar && date == other.date
end

#numberObject



29
30
31
# File 'lib/cal/day.rb', line 29

def number
  date.day
end

#succObject



25
26
27
# File 'lib/cal/day.rb', line 25

def succ
  self.class.new date.tomorrow, calendar
end