timeboss 0.1.0 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -4
  3. data/.replit +2 -0
  4. data/README.md +15 -8
  5. data/bin/tbsh +1 -1
  6. data/lib/tasks/calendars.rake +4 -2
  7. data/lib/timeboss/calendar.rb +9 -1
  8. data/lib/timeboss/calendar/day.rb +0 -1
  9. data/lib/timeboss/calendar/half.rb +0 -1
  10. data/lib/timeboss/calendar/month.rb +0 -1
  11. data/lib/timeboss/calendar/parser.rb +0 -1
  12. data/lib/timeboss/calendar/period.rb +0 -1
  13. data/lib/timeboss/calendar/quarter.rb +0 -1
  14. data/lib/timeboss/calendar/support/formatter.rb +3 -2
  15. data/lib/timeboss/calendar/support/month_basis.rb +0 -2
  16. data/lib/timeboss/calendar/support/monthly_unit.rb +0 -2
  17. data/lib/timeboss/calendar/support/navigable.rb +0 -1
  18. data/lib/timeboss/calendar/support/shiftable.rb +218 -29
  19. data/lib/timeboss/calendar/support/translatable.rb +92 -0
  20. data/lib/timeboss/calendar/support/unit.rb +4 -1
  21. data/lib/timeboss/calendar/waypoints.rb +0 -1
  22. data/lib/timeboss/calendar/waypoints/absolute.rb +0 -1
  23. data/lib/timeboss/calendar/waypoints/relative.rb +0 -1
  24. data/lib/timeboss/calendar/week.rb +1 -1
  25. data/lib/timeboss/calendar/year.rb +0 -1
  26. data/lib/timeboss/calendars.rb +0 -1
  27. data/lib/timeboss/calendars/gregorian.rb +28 -0
  28. data/lib/timeboss/version.rb +1 -1
  29. data/spec/calendar/support/monthly_unit_spec.rb +6 -0
  30. data/spec/calendar/week_spec.rb +6 -1
  31. data/spec/calendars/gregorian_spec.rb +685 -0
  32. metadata +7 -49
  33. data/doc/TimeBoss.html +0 -146
  34. data/doc/TimeBoss/Calendar.html +0 -137
  35. data/doc/TimeBoss/Calendar/Day.html +0 -594
  36. data/doc/TimeBoss/Calendar/Half.html +0 -396
  37. data/doc/TimeBoss/Calendar/Month.html +0 -396
  38. data/doc/TimeBoss/Calendar/Parser.html +0 -386
  39. data/doc/TimeBoss/Calendar/Period.html +0 -841
  40. data/doc/TimeBoss/Calendar/Quarter.html +0 -396
  41. data/doc/TimeBoss/Calendar/Support.html +0 -131
  42. data/doc/TimeBoss/Calendar/Support/Formatter.html +0 -459
  43. data/doc/TimeBoss/Calendar/Support/MonthBased.html +0 -591
  44. data/doc/TimeBoss/Calendar/Support/MonthBasis.html +0 -437
  45. data/doc/TimeBoss/Calendar/Support/MonthlyUnit.html +0 -591
  46. data/doc/TimeBoss/Calendar/Support/Navigable.html +0 -723
  47. data/doc/TimeBoss/Calendar/Support/Shiftable.html +0 -138
  48. data/doc/TimeBoss/Calendar/Support/Unit.html +0 -1299
  49. data/doc/TimeBoss/Calendar/Waypoints.html +0 -155
  50. data/doc/TimeBoss/Calendar/Waypoints/Absolute.html +0 -1378
  51. data/doc/TimeBoss/Calendar/Waypoints/Relative.html +0 -4308
  52. data/doc/TimeBoss/Calendar/Week.html +0 -671
  53. data/doc/TimeBoss/Calendar/Year.html +0 -319
  54. data/doc/TimeBoss/Calendars.html +0 -336
  55. data/doc/TimeBoss/Calendars/Broadcast.html +0 -221
  56. data/doc/TimeBoss/Calendars/Broadcast/Basis.html +0 -278
  57. data/doc/TimeBoss/Calendars/Entry.html +0 -399
  58. data/doc/TimeBoss/Support.html +0 -115
  59. data/doc/TimeBoss/Support/Shellable.html +0 -249
  60. data/doc/_index.html +0 -416
  61. data/doc/class_list.html +0 -51
  62. data/doc/css/common.css +0 -1
  63. data/doc/css/full_list.css +0 -58
  64. data/doc/css/style.css +0 -496
  65. data/doc/file.README.html +0 -299
  66. data/doc/file_list.html +0 -56
  67. data/doc/frames.html +0 -17
  68. data/doc/index.html +0 -299
  69. data/doc/js/app.js +0 -314
  70. data/doc/js/full_list.js +0 -216
  71. data/doc/js/jquery.js +0 -4
  72. data/doc/method_list.html +0 -1139
  73. data/doc/top-level-namespace.html +0 -110
  74. data/lib/timeboss/calendar/support.rb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ad33c552922fb61c6b798d0c32ab7b125d561b1d0aae10eae486317d65ed624
4
- data.tar.gz: 9744c0da3d9d10b28c3a23d6c384c48dd4b2cd8b2d910e97c362dcac9c9a3bf4
3
+ metadata.gz: 7a8966731f645860d665b2a333b2996dad5e1224d25703ddfdd4f155779645df
4
+ data.tar.gz: d087b039000b8b7999eaeae1ba98526618741aef3535238551314e79446d9b8d
5
5
  SHA512:
6
- metadata.gz: 8d3a750e0901981ad30ec9bab9f3c155f13ea6689293ff5b46f574ae074ee79f712a2d5e3ba9f4dc0e10b492d4252a20b879f244d92afb1ce21417a2231530c1
7
- data.tar.gz: 8d3c3d6b5f6e4df76b69e78853758a12a347c9e65957d1ee03d55229e9f04c526ddbfc912bdc1a89407635e306b6207b06e5f8d008eed2cec260e59c0948ce6b
6
+ metadata.gz: 31c77aac0422e2ba3da7c8422014ddfa0196388c27c4d9e78775909099a6a2461d0b6d86f5f2b265fda05718711e60818f33519c17f025f4952cf7ff950444e2
7
+ data.tar.gz: a5cbb8b93686382b75222a191405de36449d725dee28db2dd396c9d8e394fa41d8da7dd41229c3c9674d7ba6c2ad78f9fe03f720a3279d47f0f4cc14eb41d939
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
- /*.gem
2
- /Gemfile.lock
3
- /.bundle
4
- /.yardoc
1
+ *.gem
2
+ Gemfile.lock
3
+ .bundle
4
+ .yardoc
5
+ doc
data/.replit ADDED
@@ -0,0 +1,2 @@
1
+ language = "ruby"
2
+ run = "rake timeboss:calendars:broadcast:repl"
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
- # TimeBoss [![Build Status](https://travis-ci.com/kevinstuffandthings/timeboss.svg?branch=master)](https://travis-ci.com/kevinstuffandthings/timeboss) [![Gem Version](https://badge.fury.io/rb/timeboss.svg)](https://badge.fury.io/rb/timeboss)
2
- A gem providing convenient navigation of the [Broadcast Calendar](https://en.wikipedia.org/wiki/Broadcast_calendar).
1
+ # TimeBoss [![Build Status](https://travis-ci.com/kevinstuffandthings/timeboss.svg?branch=master)](https://travis-ci.com/kevinstuffandthings/timeboss) [![Gem Version](https://badge.fury.io/rb/timeboss.svg)](https://badge.fury.io/rb/timeboss) [![Run on Repl.it](https://repl.it/badge/github/kevinstuffandthings/timeboss)](https://repl.it/github/kevinstuffandthings/timeboss)
2
+
3
+ A gem providing convenient navigation of the [Broadcast Calendar](https://en.wikipedia.org/wiki/Broadcast_calendar), the standard Gregorian calendar, and is easily extensible to support multiple financial calendars.
4
+
3
5
  Originally developed for [Simulmedia](https://simulmedia.com).
4
6
 
5
7
  ## Installation
@@ -23,7 +25,7 @@ $ gem install timeboss
23
25
  ```
24
26
 
25
27
  ## Usage
26
- Supports `year`, `half`, `quarter`, `month`, `week`, and `day`.
28
+ Supports `year`, `half`, `quarter`, `month`, `week` (non-gregorian calendars only), and `day`.
27
29
 
28
30
  Prepare your calendar for use:
29
31
 
@@ -131,11 +133,16 @@ period = calendar.parse('2020W3..2020Q1')
131
133
  # => "2020W3 .. 2020Q1: from 2020-01-13 thru 2020-03-29 (current=false)"
132
134
  ```
133
135
 
134
- The examples above are just samples. Try different periods, operators, etc.
136
+ The examples above are just samples. Try different periods, operators, etc. All of the non-week-based operations will work similarly on the `TimeBoss::Calendars::Gregorian` calendar.
137
+
138
+ ### REPL
139
+ To open a REPL for the broadcast calendar, use the `tbsh` executable, or the `timeboss:calendars:broadcast:repl` rake task.
140
+
141
+ For the Gregorian calendar (or any other implemented calendars), supply the name on the command line.
142
+ - `tbsh gregorian`
143
+ - `rake timeboss:calendars:gregorian:repl`
135
144
 
136
- ### Shell
137
- To open an IRB shell for the broadcast calendar, use the `tbsh` executable, or the `timeboss:calendars:broadcast:shell` rake task.
138
- You will find yourself in the context of an instantiated `TimeBoss::Calendars::Broadcast` object:
145
+ You will find yourself in the context of an instantiated `TimeBoss::Calendar` object:
139
146
 
140
147
  ```bash
141
148
  $ tbsh
@@ -147,7 +154,7 @@ $ tbsh
147
154
  => ["2020M7", "2020M8", "2020M9", "2020M10", "2020M11", "2020M12", "2021M1", "2021M2", "2021M3", "2021M4", "2021M5", "2021M6", "2021M7", "2021M8", "2021M9"]
148
155
  ```
149
156
 
150
- _Having trouble with the shell? If you are using the examples from the [Usage](#Usage) section, keep in mind that the shell is already in the context of the calendar -- so you don't need to specify the receiver!_
157
+ _Having trouble with the REPL? If you are using the examples from the [Usage](#Usage) section, keep in mind that the REPL is already in the context of the calendar -- so you don't need to specify the receiver!_
151
158
 
152
159
  ## Creating new calendars
153
160
  To create a custom calendar, simply extend the `TimeBoss::Calendar` class, and implement a new `TimeBoss::Calendar::Support::MonthBasis` for it.
data/bin/tbsh CHANGED
@@ -4,7 +4,7 @@ require 'timeboss/calendars'
4
4
  require 'timeboss/support/shellable'
5
5
 
6
6
  calendar = if ARGV.length == 1
7
- TimeBoss::Calendars[ARGV.first]&.calendar
7
+ TimeBoss::Calendars[ARGV.first]
8
8
  else
9
9
  TimeBoss::Calendars.first.calendar
10
10
  end
@@ -9,11 +9,13 @@ namespace :timeboss do
9
9
  puts entry.calendar.parse(args[:expression])
10
10
  end
11
11
 
12
- desc "Open a shell with the #{entry.name} calendar"
13
- task shell: ['timeboss:init'] do
12
+ desc "Open a REPL with the #{entry.name} calendar"
13
+ task repl: ['timeboss:init'] do
14
14
  require 'timeboss/support/shellable'
15
15
  TimeBoss::Support::Shellable.open(entry.calendar)
16
16
  end
17
+
18
+ task shell: ["timeboss:calendars:#{entry.name}:repl"]
17
19
  end
18
20
  end
19
21
  end
@@ -7,7 +7,6 @@ require 'active_support/core_ext/numeric/time'
7
7
  require_relative './calendar/support/month_basis'
8
8
 
9
9
  module TimeBoss
10
- # A calendar is built upon a basis, and provides methods for period identification and navigation.
11
10
  class Calendar
12
11
  include Waypoints
13
12
 
@@ -26,6 +25,7 @@ module TimeBoss
26
25
  def name
27
26
  self.class.to_s.demodulize.underscore
28
27
  end
28
+ alias_method :to_s, :name
29
29
 
30
30
  # Get a friendly title for this calendar.
31
31
  # @return [String]
@@ -33,6 +33,14 @@ module TimeBoss
33
33
  name.titleize
34
34
  end
35
35
 
36
+ # Can this calendar support weeks?
37
+ # For custom calendars, this value can generally not be overridden.
38
+ # But for calendars like our Gregorian implementation, weeks are irrelevant, and should be suppressed.
39
+ # @return [Boolean]
40
+ def supports_weeks?
41
+ true
42
+ end
43
+
36
44
  protected
37
45
 
38
46
  attr_reader :basis
@@ -3,7 +3,6 @@ require_relative './support/unit'
3
3
 
4
4
  module TimeBoss
5
5
  class Calendar
6
- # Representation of a single day within a calendar.
7
6
  class Day < Support::Unit
8
7
  def initialize(calendar, start_date)
9
8
  super(calendar, start_date, start_date)
@@ -3,7 +3,6 @@ require_relative './support/monthly_unit'
3
3
 
4
4
  module TimeBoss
5
5
  class Calendar
6
- # Representation of a 6-month period within a calendar.
7
6
  class Half < Support::MonthlyUnit
8
7
  NUM_MONTHS = 6
9
8
 
@@ -3,7 +3,6 @@ require_relative './support/monthly_unit'
3
3
 
4
4
  module TimeBoss
5
5
  class Calendar
6
- # Representation of a single month within a calendar.
7
6
  class Month < Support::MonthlyUnit
8
7
  NUM_MONTHS = 1
9
8
 
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module TimeBoss
3
3
  class Calendar
4
- # The parser is responsible for the implementation of a calendar's identifier parsing abilities.
5
4
  class Parser
6
5
  RANGE_DELIMITER = '..'
7
6
  InvalidPeriodIdentifierError = Class.new(StandardError)
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module TimeBoss
3
3
  class Calendar
4
- # A calendar period represents a range of units.
5
4
  class Period
6
5
  attr_reader :begin, :end
7
6
 
@@ -3,7 +3,6 @@ require_relative './support/monthly_unit'
3
3
 
4
4
  module TimeBoss
5
5
  class Calendar
6
- # Representation of a 3-month period within a calendar.
7
6
  class Quarter < Support::MonthlyUnit
8
7
  NUM_MONTHS = 3
9
8
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require_relative './shiftable'
2
+ require_relative './translatable'
3
3
 
4
4
  module TimeBoss
5
5
  class Calendar
@@ -8,12 +8,13 @@ module TimeBoss
8
8
 
9
9
  # The formatter is responsible for the implementation of name formatting for a unit.
10
10
  class Formatter
11
- PERIODS = Shiftable::PERIODS.reverse.map(&:to_sym).drop(1)
11
+ PERIODS = Translatable::PERIODS.reverse.map(&:to_sym).drop(1)
12
12
  attr_reader :unit, :periods
13
13
 
14
14
  def initialize(unit, periods)
15
15
  @unit = unit
16
16
  @periods = PERIODS & periods.map(&:to_sym).push(unit.class.type.to_sym)
17
+ @periods -= [:week] unless unit.calendar.supports_weeks?
17
18
  end
18
19
 
19
20
  def to_s
@@ -2,8 +2,6 @@ module TimeBoss
2
2
  class Calendar
3
3
  module Support
4
4
  # @abstract
5
- # Implementation of a month basis allows a custom calendar to be built.
6
- # A month basis must return a start/end date for a given year and month index.
7
5
  class MonthBasis
8
6
  attr_reader :year, :month
9
7
 
@@ -4,8 +4,6 @@ require_relative './unit'
4
4
  module TimeBoss
5
5
  class Calendar
6
6
  module Support
7
- # Units that are built off of month-granularities (months, quarters, etc).
8
- # Days and weeks are not built from these.
9
7
  class MonthlyUnit < Unit
10
8
  attr_reader :year_index, :index
11
9
 
@@ -2,7 +2,6 @@
2
2
  module TimeBoss
3
3
  class Calendar
4
4
  module Support
5
- # Provides navigational abilities for units within a calendar.
6
5
  module Navigable
7
6
  # @overload previous
8
7
  # Fetch the previous unit relative to this unit.
@@ -2,50 +2,239 @@
2
2
  module TimeBoss
3
3
  class Calendar
4
4
  module Support
5
- # Provides the ability to take a unit, and shift it into a different period, relative to today.
6
5
  module Shiftable
7
- PERIODS = %w[day week month quarter half year]
8
-
9
- PERIODS.each do |period|
6
+ Support::Translatable::PERIODS.each do |period|
10
7
  periods = period.pluralize
11
8
 
12
- define_method periods do
13
- calendar.send("#{periods}_for", self)
14
- end
15
-
16
- define_method period do
17
- entries = send(periods)
18
- return nil unless entries.length == 1
19
- entries.first
20
- end
21
-
22
- define_method "in_#{period}" do
9
+ define_method("in_#{period}") do
23
10
  base = send(periods)
24
11
  return unless base.length == 1
25
12
  base.first.send(self.class.type.to_s.pluralize).find_index { |p| p == self } + 1
26
13
  end
27
14
 
28
- define_method "#{periods}_ago" do |offset|
15
+ define_method("#{periods}_ago") do |offset|
29
16
  base_offset = send("in_#{period}") or return
30
17
  (calendar.send("this_#{period}") - offset).send(self.class.type.to_s.pluralize)[base_offset - 1]
31
18
  end
32
19
 
33
- define_method "last_#{period}" do
34
- send("#{periods}_ago", 1)
35
- end
20
+ define_method("#{periods}_ahead") { |o| send("#{periods}_ago", o * -1) }
36
21
 
37
- define_method "this_#{period}" do
38
- send("#{periods}_ago", 0)
39
- end
22
+ define_method("last_#{period}") { send("#{periods}_ago", 1) }
23
+ define_method("this_#{period}") { send("#{periods}_ago", 0) }
24
+ define_method("next_#{period}") { send("#{periods}_ahead", 1) }
25
+ end
40
26
 
41
- define_method "#{periods}_ahead" do |offset|
42
- send("#{periods}_ago", offset * -1)
43
- end
27
+ alias_method :yesterday, :last_day
28
+ alias_method :today, :this_day
29
+ alias_method :tomorrow, :next_day
44
30
 
45
- define_method "next_#{period}" do
46
- send("#{periods}_ahead", 1)
47
- end
48
- end
31
+ #
32
+ # i hate this
33
+ #
34
+
35
+ ### Days
36
+
37
+ # @!method in_day
38
+ # Get the index within the day that this unit falls in.
39
+ # Returns nil if no single day can be identified.
40
+ # @return [Integer, nil]
41
+
42
+ # @!method days_ago
43
+ # Get the index-relative day some number of days ago.
44
+ # Returns nil if no single day can be identified.
45
+ # @param offset [Integer] the number of days back to shift this period
46
+ # @return [Calendar::Day, nil]
47
+
48
+ # @!method days_ahead
49
+ # Get the index-relative day some number of days ahead.
50
+ # Returns nil if no single day can be identified.
51
+ # @param offset [Integer] the number of days forward to shift this period
52
+ # @return [Calendar::Day, nil]
53
+
54
+ # @!method last_day
55
+ # Get the index-relative day 1 day ago.
56
+ # Returns nil if no single day can be identified.
57
+ # @return [Calendar::Day, nil]
58
+
59
+ # @!method this_day
60
+ # Get the index-relative day for this day.
61
+ # Returns nil if no single day can be identified.
62
+ # @return [Calendar::Day, nil]
63
+
64
+ # @!method next_day
65
+ # Get the index-relative day 1 day forward.
66
+ # Returns nil if no single day can be identified.
67
+ # @return [Calendar::Day, nil]
68
+
69
+ ### Weeks
70
+
71
+ # @!method in_week
72
+ # Get the index within the week that this unit falls in.
73
+ # Returns nil if no single week can be identified.
74
+ # @return [Integer, nil]
75
+
76
+ # @!method weeks_ago
77
+ # Get the index-relative week some number of weeks ago.
78
+ # Returns nil if no single week can be identified.
79
+ # @param offset [Integer] the number of weeks back to shift this period
80
+ # @return [Calendar::Week, nil]
81
+
82
+ # @!method weeks_ahead
83
+ # Get the index-relative week some number of weeks ahead.
84
+ # Returns nil if no single week can be identified.
85
+ # @param offset [Integer] the number of weeks forward to shift this period
86
+ # @return [Calendar::Week, nil]
87
+
88
+ # @!method last_week
89
+ # Get the index-relative week 1 week ago.
90
+ # Returns nil if no single week can be identified.
91
+ # @return [Calendar::Week, nil]
92
+
93
+ # @!method this_week
94
+ # Get the index-relative week for this week.
95
+ # Returns nil if no single week can be identified.
96
+ # @return [Calendar::Week, nil]
97
+
98
+ # @!method next_week
99
+ # Get the index-relative week 1 week forward.
100
+ # Returns nil if no single week can be identified.
101
+ # @return [Calendar::Week, nil]
102
+
103
+ ### Months
104
+
105
+ # @!method in_month
106
+ # Get the index within the month that this unit falls in.
107
+ # Returns nil if no single month can be identified.
108
+ # @return [Integer, nil]
109
+
110
+ # @!method months_ago
111
+ # Get the index-relative month some number of months ago.
112
+ # Returns nil if no single month can be identified.
113
+ # @param offset [Integer] the number of months back to shift this period
114
+ # @return [Calendar::Month, nil]
115
+
116
+ # @!method months_ahead
117
+ # Get the index-relative month some number of months ahead.
118
+ # Returns nil if no single month can be identified.
119
+ # @param offset [Integer] the number of months forward to shift this period
120
+ # @return [Calendar::Month, nil]
121
+
122
+ # @!method last_month
123
+ # Get the index-relative month 1 month ago.
124
+ # Returns nil if no single month can be identified.
125
+ # @return [Calendar::Month, nil]
126
+
127
+ # @!method this_month
128
+ # Get the index-relative month for this month.
129
+ # Returns nil if no single month can be identified.
130
+ # @return [Calendar::Month, nil]
131
+
132
+ # @!method next_month
133
+ # Get the index-relative month 1 month forward.
134
+ # Returns nil if no single month can be identified.
135
+ # @return [Calendar::Month, nil]
136
+
137
+ ### Quarters
138
+
139
+ # @!method in_quarter
140
+ # Get the index within the quarter that this unit falls in.
141
+ # Returns nil if no single quarter can be identified.
142
+ # @return [Integer, nil]
143
+
144
+ # @!method quarters_ago
145
+ # Get the index-relative quarter some number of quarters ago.
146
+ # Returns nil if no single quarter can be identified.
147
+ # @param offset [Integer] the number of quarters back to shift this period
148
+ # @return [Calendar::Quarter, nil]
149
+
150
+ # @!method quarters_ahead
151
+ # Get the index-relative quarter some number of quarters ahead.
152
+ # Returns nil if no single quarter can be identified.
153
+ # @param offset [Integer] the number of quarters forward to shift this period
154
+ # @return [Calendar::Quarter, nil]
155
+
156
+ # @!method last_quarter
157
+ # Get the index-relative quarter 1 quarter ago.
158
+ # Returns nil if no single quarter can be identified.
159
+ # @return [Calendar::Quarter, nil]
160
+
161
+ # @!method this_quarter
162
+ # Get the index-relative quarter for this quarter.
163
+ # Returns nil if no single quarter can be identified.
164
+ # @return [Calendar::Quarter, nil]
165
+
166
+ # @!method next_quarter
167
+ # Get the index-relative quarter 1 quarter forward.
168
+ # Returns nil if no single quarter can be identified.
169
+ # @return [Calendar::Quarter, nil]
170
+
171
+ ### Halves
172
+
173
+ # @!method in_half
174
+ # Get the index within the half that this unit falls in.
175
+ # Returns nil if no single half can be identified.
176
+ # @return [Integer, nil]
177
+
178
+ # @!method halves_ago
179
+ # Get the index-relative half some number of halves ago.
180
+ # Returns nil if no single half can be identified.
181
+ # @param offset [Integer] the number of halves back to shift this period
182
+ # @return [Calendar::Half, nil]
183
+
184
+ # @!method halves_ahead
185
+ # Get the index-relative half some number of halves ahead.
186
+ # Returns nil if no single half can be identified.
187
+ # @param offset [Integer] the number of halves forward to shift this period
188
+ # @return [Calendar::Half, nil]
189
+
190
+ # @!method last_half
191
+ # Get the index-relative half 1 half ago.
192
+ # Returns nil if no single half can be identified.
193
+ # @return [Calendar::Half, nil]
194
+
195
+ # @!method this_half
196
+ # Get the index-relative half for this half.
197
+ # Returns nil if no single half can be identified.
198
+ # @return [Calendar::Half, nil]
199
+
200
+ # @!method next_half
201
+ # Get the index-relative half 1 half forward.
202
+ # Returns nil if no single half can be identified.
203
+ # @return [Calendar::Half, nil]
204
+
205
+ ### Years
206
+
207
+ # @!method in_year
208
+ # Get the index within the year that this unit falls in.
209
+ # Returns nil if no single year can be identified.
210
+ # @return [Integer, nil]
211
+
212
+ # @!method years_ago
213
+ # Get the index-relative year some number of years ago.
214
+ # Returns nil if no single year can be identified.
215
+ # @param offset [Integer] the number of years back to shift this period
216
+ # @return [Calendar::Year, nil]
217
+
218
+ # @!method years_ahead
219
+ # Get the index-relative year some number of years ahead.
220
+ # Returns nil if no single year can be identified.
221
+ # @param offset [Integer] the number of years forward to shift this period
222
+ # @return [Calendar::Year, nil]
223
+
224
+ # @!method last_year
225
+ # Get the index-relative year 1 year ago.
226
+ # Returns nil if no single year can be identified.
227
+ # @return [Calendar::Year, nil]
228
+
229
+ # @!method this_year
230
+ # Get the index-relative year for this year.
231
+ # Returns nil if no single year can be identified.
232
+ # @return [Calendar::Year, nil]
233
+
234
+ # @!method next_year
235
+ # Get the index-relative year 1 year forward.
236
+ # Returns nil if no single year can be identified.
237
+ # @return [Calendar::Year, nil]
49
238
  end
50
239
  end
51
240
  end