Class: Chronic::Season
- Inherits:
-
Object
- Object
- Chronic::Season
- Defined in:
- lib/chronic/season.rb
Instance Attribute Summary collapse
- #end ⇒ MiniDate readonly
- #start ⇒ MiniDate readonly
Class Method Summary collapse
-
.find_next_season(season, pointer) ⇒ Symbol
The new season name.
-
.season_after(season) ⇒ Symbol
The new season name.
-
.season_before(season) ⇒ Symbol
The new season name.
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.
11 12 13 14 |
# File 'lib/chronic/season.rb', line 11 def initialize(start_date, end_date) @start = start_date @end = end_date end |
Instance Attribute Details
Class Method Details
.find_next_season(season, pointer) ⇒ Symbol
Returns The new season name.
19 20 21 22 23 |
# File 'lib/chronic/season.rb', line 19 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) ⇒ Symbol
Returns The new season name.
27 28 29 |
# File 'lib/chronic/season.rb', line 27 def self.season_after(season) find_next_season(season, +1) end |
.season_before(season) ⇒ Symbol
Returns The new season name.
33 34 35 |
# File 'lib/chronic/season.rb', line 33 def self.season_before(season) find_next_season(season, -1) end |