Class: Chronic::Season
- Inherits:
-
Object
- Object
- Chronic::Season
- Defined in:
- lib/chronic/season.rb
Instance Attribute Summary collapse
-
#end ⇒ Object
readonly
Returns the value of attribute end.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
Class Method Summary collapse
- .find_next_season(season, pointer) ⇒ Object
- .season_after(season) ⇒ Object
- .season_before(season) ⇒ Object
Instance Method Summary collapse
-
#initialize(start_date, end_date) ⇒ Season
constructor
A new instance of Season.
Constructor Details
#initialize(start_date, end_date) ⇒ Season
Returns a new instance of Season.
7 8 9 10 |
# File 'lib/chronic/season.rb', line 7 def initialize(start_date, end_date) @start = start_date @end = end_date end |
Instance Attribute Details
#end ⇒ Object (readonly)
Returns the value of attribute end.
5 6 7 |
# File 'lib/chronic/season.rb', line 5 def end @end end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
4 5 6 |
# File 'lib/chronic/season.rb', line 4 def start @start end |
Class Method Details
.find_next_season(season, pointer) ⇒ Object
12 13 14 15 16 |
# File 'lib/chronic/season.rb', line 12 def self.find_next_season(season, pointer) lookup = [:spring, :summer, :autumn, :winter] next_season_num = (lookup.index(season) + 1 * pointer) % 4 lookup[next_season_num] end |
.season_after(season) ⇒ Object
18 19 20 |
# File 'lib/chronic/season.rb', line 18 def self.season_after(season) find_next_season(season, +1) end |
.season_before(season) ⇒ Object
22 23 24 |
# File 'lib/chronic/season.rb', line 22 def self.season_before(season) find_next_season(season, -1) end |