Class: Season

Inherits:
Object
  • Object
show all
Defined in:
lib/chronic/repeaters/repeater_season.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(myStart, myEnd) ⇒ Season

Returns a new instance of Season.


10
11
12
13
# File 'lib/chronic/repeaters/repeater_season.rb', line 10

def initialize(myStart, myEnd)
  @start = myStart
  @end = myEnd
end

Instance Attribute Details

#endObject (readonly)

Returns the value of attribute end


8
9
10
# File 'lib/chronic/repeaters/repeater_season.rb', line 8

def end
  @end
end

#startObject (readonly)

Returns the value of attribute start


8
9
10
# File 'lib/chronic/repeaters/repeater_season.rb', line 8

def start
  @start
end

Class Method Details

.find_next_season(season, pointer) ⇒ Object


15
16
17
18
19
# File 'lib/chronic/repeaters/repeater_season.rb', line 15

def self.find_next_season(season, pointer)
  lookup = {:spring => 0, :summer => 1, :autumn => 2, :winter => 3}
  next_season_num = (lookup[season]+1*pointer) % 4
  lookup.invert[next_season_num]
end

.season_after(season) ⇒ Object


21
# File 'lib/chronic/repeaters/repeater_season.rb', line 21

def self.season_after(season); find_next_season(season, +1); end

.season_before(season) ⇒ Object


22
# File 'lib/chronic/repeaters/repeater_season.rb', line 22

def self.season_before(season); find_next_season(season, -1); end