Class: Sheha::YearlyEvent

Inherits:
Event
  • Object
show all
Defined in:
lib/sheha/yearly_event.rb

Instance Attribute Summary

Attributes inherited from Event

#description, #name

Instance Method Summary collapse

Methods inherited from Event

#<=>, #==, #eql?, #hash

Constructor Details

#initialize(month, month_day) ⇒ YearlyEvent

Returns a new instance of YearlyEvent.



2
3
4
5
6
# File 'lib/sheha/yearly_event.rb', line 2

def initialize(month, month_day)
  Sheha::Helper.validate_month(month)
  Sheha::Helper.validate_month_day(month_day)
  super "#{month}#{month_day}".to_i
end

Instance Method Details

#event?(date) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/sheha/yearly_event.rb', line 26

def event?(date)
  month == date.month && month_day == date.day
end

#monthObject



8
9
10
# File 'lib/sheha/yearly_event.rb', line 8

def month
  "#{four_digits_id[0..1]}".to_i
end

#month=(month) ⇒ Object



12
13
14
15
# File 'lib/sheha/yearly_event.rb', line 12

def month=(month)
  Sheha::Helper.validate_month(month)
  @id = "#{month}#{four_digits_id[2..3]}".to_i
end

#month_dayObject



17
18
19
# File 'lib/sheha/yearly_event.rb', line 17

def month_day
  "#{four_digits_id[2..3]}".to_i
end

#month_day=(month_day) ⇒ Object



21
22
23
24
# File 'lib/sheha/yearly_event.rb', line 21

def month_day=(month_day)
  Sheha::Helper.validate_month_day(month_day)
  @id = "#{four_digits_id[0..1]}#{month_day}".to_i
end

#succObject



30
31
32
# File 'lib/sheha/yearly_event.rb', line 30

def succ
  self.class.new(succ_month, succ_month_day)
end