nickel 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4749a62cf4e0593e14a0add9a87e83ab42c0e22a
4
- data.tar.gz: 89f4306d7c4600d52ef806ef776dc2ebfaba4880
3
+ metadata.gz: 049bc00c9192feea793d0fbc601880a7ed453d3f
4
+ data.tar.gz: b1c556a1bc2aaf376477a0252ebd4db4b79898cd
5
5
  SHA512:
6
- metadata.gz: a679225d669ab812a0c260f8bef2012047aa24a709838b869228ab32eff4db78c1f65d81903b046a23746410542e2d563d03cb88077f24ec7d3c0af3c9d9c2b0
7
- data.tar.gz: b9febf74771b71217f1ce05148bd17dd4939c3eb60b7d8f51856ddd9f30d221cd0fcf18d80bf7f9323a31a1f3d9f67d8dac36b2d9180dbf2e5fd8299c4dbc0f7
6
+ metadata.gz: d6ae52647afa53f7e4c337d3df175cccc7bb6d86e719dca010279b47cff373508286ab87b7d637d0d412c8b4badfed1a9b9ada5ebfa2cd69ffd6fa64b00b7f3f
7
+ data.tar.gz: bc62a764521b3f4d41a4afd5a446a149f5461d794c79951e553075811dd0f2672aec2b9ff4cf65ecb5222251f18f78be05edb53295e347bae76019bcd3050695
@@ -1,3 +1,11 @@
1
+ 0.1.2
2
+ -----
3
+ * Deprecated ZDate#is_today?, ZTime#is_am? and RecurrenceConstruct#get_interval
4
+
5
+ 0.1.1
6
+ -----
7
+ * Made ZDate#before?, ZDate#after?, ZTime#before? and ZTime#after? private methods
8
+
1
9
  0.1.0
2
10
  -----
3
11
 
data/Rakefile CHANGED
@@ -1,5 +1,8 @@
1
+ require 'bundler'
2
+ Bundler.setup
3
+ Bundler::GemHelper.install_tasks
4
+
1
5
  require 'rake'
2
- require 'bundler/gem_tasks'
3
6
  require 'rspec/core/rake_task'
4
7
  require 'coveralls/rake/task'
5
8
  require 'yard'
@@ -11,4 +14,5 @@ RSpec::Core::RakeTask.new(:spec)
11
14
  YARD::Rake::YardocTask.new(:yard)
12
15
 
13
16
  Coveralls::RakeTask.new
17
+
14
18
  task test_with_coveralls: [:spec, 'coveralls:push']
@@ -1,16 +1,15 @@
1
1
  module Nickel
2
-
3
2
  class Construct
4
3
  attr_accessor :comp_start, :comp_end, :found_in
5
4
  def initialize(h)
6
- h.each { |k,v| send("#{k}=", v) }
5
+ h.each { |k, v| send("#{k}=", v) }
7
6
  end
8
7
  end
9
8
 
10
9
  class DateConstruct < Construct
11
10
  attr_accessor :date
12
11
  def interpret
13
- {:date => date}
12
+ { date: date }
14
13
  end
15
14
  end
16
15
 
@@ -21,7 +20,7 @@ module Nickel
21
20
  class TimeConstruct < Construct
22
21
  attr_accessor :time
23
22
  def interpret
24
- {:time => time}
23
+ { time: time }
25
24
  end
26
25
  end
27
26
 
@@ -37,54 +36,50 @@ module Nickel
37
36
  attr_accessor :repeats, :repeats_on
38
37
 
39
38
  def interpret
40
- if variant_of?(:daily) then interpret_daily_variant
41
- elsif variant_of?(:weekly) then interpret_weekly_variant
42
- elsif variant_of?(:daymonthly) then interpret_daymonthly_variant
43
- elsif variant_of?(:datemonthly) then interpret_datemonthly_variant
39
+ if [:daily, :altdaily, :threedaily].include?(repeats)
40
+ interpret_daily_variant
41
+ elsif [:weekly, :altweekly, :threeweekly].include?(repeats)
42
+ interpret_weekly_variant
43
+ elsif [:daymonthly, :altdaymonthly, :threedaymonthly].include?(repeats)
44
+ interpret_daymonthly_variant
45
+ elsif [:datemonthly, :altdatemonthly, :threedatemonthly].include?(repeats)
46
+ interpret_datemonthly_variant
44
47
  else
45
- raise StandardError.new("self is an invalid variant, check value of self.repeats")
48
+ fail StandardError, 'self is an invalid variant, check value of self.repeats'
46
49
  end
47
50
  end
48
51
 
49
52
  def get_interval
50
- if has_interval_of?(1) then 1
51
- elsif has_interval_of?(2) then 2
52
- elsif has_interval_of?(3) then 3
53
- else
54
- raise StandardError.new("self.repeats is invalid!!")
55
- end
53
+ warn '[DEPRECATION] `get_interval` is deprecated. Please use `interval` instead.'
54
+ interval
56
55
  end
57
56
 
58
- private
59
- def has_interval_of?(x)
60
- case x
61
- when 1 then [:daily, :weekly, :daymonthly, :datemonthly].include?(repeats)
62
- when 2 then [:altdaily, :altweekly, :altdaymonthly, :altdatemonthly].include?(repeats)
63
- when 3 then [:threedaily, :threeweekly, :threedaymonthly, :threedatemonthly].include?(repeats)
57
+ def interval
58
+ if [:daily, :weekly, :daymonthly, :datemonthly].include?(repeats)
59
+ 1
60
+ elsif [:altdaily, :altweekly, :altdaymonthly, :altdatemonthly].include?(repeats)
61
+ 2
62
+ elsif [:threedaily, :threeweekly, :threedaymonthly, :threedatemonthly].include?(repeats)
63
+ 3
64
+ else
65
+ fail StandardError, 'self.repeats is invalid!!'
64
66
  end
65
67
  end
66
68
 
67
- def variant_of?(sym)
68
- case sym
69
- when :daily then [:daily, :altdaily, :threedaily].include?(repeats)
70
- when :weekly then [:weekly, :altweekly, :threeweekly].include?(repeats)
71
- when :daymonthly then [:daymonthly, :altdaymonthly, :threedaymonthly].include?(repeats)
72
- when :datemonthly then [:datemonthly, :altdatemonthly, :threedatemonthly].include?(repeats)
73
- end
74
- end
69
+ private
75
70
 
76
71
  def interpret_daily_variant
77
- hash_for_occ_base = {:type => :daily, :interval => get_interval}
72
+ hash_for_occ_base = { type: :daily, interval: interval }
78
73
  [hash_for_occ_base]
79
74
  end
80
75
 
81
76
  # repeats_on is an array of day indices. For example,
82
77
  # "every monday and wed" will produce repeats_on == [0,2].
83
78
  def interpret_weekly_variant
84
- hash_for_occ_base = {:type => :weekly, :interval => get_interval}
79
+ hash_for_occ_base = { type: :weekly, interval: interval }
85
80
  array_of_occurrences = []
86
81
  repeats_on.each do |day_of_week|
87
- array_of_occurrences << hash_for_occ_base.merge({:day_of_week => day_of_week})
82
+ array_of_occurrences << hash_for_occ_base.merge(day_of_week: day_of_week)
88
83
  end
89
84
  array_of_occurrences
90
85
  end
@@ -94,10 +89,10 @@ module Nickel
94
89
  # "the first and second sat of every month" will produce
95
90
  # repeats_on == [[1,5], [2,5]]
96
91
  def interpret_daymonthly_variant
97
- hash_for_occ_base = {:type => :daymonthly, :interval => get_interval}
92
+ hash_for_occ_base = { type: :daymonthly, interval: interval }
98
93
  array_of_occurrences = []
99
94
  repeats_on.each do |on|
100
- h = {:week_of_month => on[0], :day_of_week => on[1]}
95
+ h = { week_of_month: on[0], day_of_week: on[1] }
101
96
  array_of_occurrences << hash_for_occ_base.merge(h)
102
97
  end
103
98
  array_of_occurrences
@@ -106,10 +101,10 @@ module Nickel
106
101
  # repeats_on is an array of datemonthly indices. For example,
107
102
  # "the 21st and 22nd of every monthy" will produce repeats_on == [21, 22]
108
103
  def interpret_datemonthly_variant
109
- hash_for_occ_base = {:type => :datemonthly, :interval => get_interval}
104
+ hash_for_occ_base = { type: :datemonthly, interval: interval }
110
105
  array_of_occurrences = []
111
106
  repeats_on.each do |date_of_month|
112
- h = {:date_of_month => date_of_month}
107
+ h = { date_of_month: date_of_month }
113
108
  array_of_occurrences << hash_for_occ_base.merge(h)
114
109
  end
115
110
  array_of_occurrences
@@ -3,7 +3,6 @@ require_relative 'zdate'
3
3
  require_relative 'ztime'
4
4
 
5
5
  module Nickel
6
-
7
6
  class ConstructFinder
8
7
  attr_reader :constructs, :components
9
8
 
@@ -38,719 +37,806 @@ module Nickel
38
37
  reset_instance_vars
39
38
 
40
39
  if match_every
41
- if match_every_dayname then found_every_dayname # every tue
42
- elsif match_every_day then found_every_day # every day
43
- elsif match_every_other
44
- if match_every_other_dayname then found_every_other_dayname # every other fri
45
- elsif match_every_other_day then found_every_other_day # every other day
46
- end
47
- elsif match_every_3rd
48
- if match_every_3rd_dayname then found_every_3rd_dayname # every third fri
49
- elsif match_every_3rd_day then found_every_3rd_day # every third day
50
- end
40
+ if match_every_dayname
41
+ found_every_dayname # every tue
42
+ elsif match_every_day
43
+ found_every_day # every day
44
+ elsif match_every_other
45
+ if match_every_other_dayname
46
+ found_every_other_dayname # every other fri
47
+ elsif match_every_other_day
48
+ found_every_other_day # every other day
49
+ end
50
+ elsif match_every_3rd
51
+ if match_every_3rd_dayname
52
+ found_every_3rd_dayname # every third fri
53
+ elsif match_every_3rd_day
54
+ found_every_3rd_day # every third day
51
55
  end
56
+ end
52
57
 
53
58
  elsif match_repeats
54
- if match_repeats_daily then found_repeats_daily # repeats daily
55
- elsif match_repeats_altdaily then found_repeats_altdaily # repeats altdaily
56
- elsif match_repeats_weekly_vague then found_repeats_weekly_vague # repeats weekly
57
- elsif match_repeats_altweekly_vague then found_repeats_altweekly_vague # repeats altweekly
58
- elsif match_repeats_monthly
59
- if match_repeats_daymonthly then found_repeats_daymonthly # repeats monthly 1st fri
60
- elsif match_repeats_datemonthly then found_repeats_datemonthly # repeats monthly 22nd
61
- end
62
- elsif match_repeats_altmonthly
63
- if match_repeats_altmonthly_daymonthly then found_repeats_altmonthly_daymonthly # repeats altmonthly 1st fri
64
- elsif match_repeats_altmonthly_datemonthly then found_repeats_altmonthly_datemonthly # repeats altmonthly 22nd
65
- end
66
- elsif match_repeats_threemonthly
67
- if match_repeats_threemonthly_daymonthly then found_repeats_threemonthly_daymonthly # repeats threemonthly 1st fri
68
- elsif match_repeats_threemonthly_datemonthly then found_repeats_threemonthly_datemonthly # repeats threemonthly 22nd
69
- end
59
+ if match_repeats_daily
60
+ found_repeats_daily # repeats daily
61
+ elsif match_repeats_altdaily
62
+ found_repeats_altdaily # repeats altdaily
63
+ elsif match_repeats_weekly_vague
64
+ found_repeats_weekly_vague # repeats weekly
65
+ elsif match_repeats_altweekly_vague
66
+ found_repeats_altweekly_vague # repeats altweekly
67
+ elsif match_repeats_monthly
68
+ if match_repeats_daymonthly
69
+ found_repeats_daymonthly # repeats monthly 1st fri
70
+ elsif match_repeats_datemonthly
71
+ found_repeats_datemonthly # repeats monthly 22nd
72
+ end
73
+ elsif match_repeats_altmonthly
74
+ if match_repeats_altmonthly_daymonthly
75
+ found_repeats_altmonthly_daymonthly # repeats altmonthly 1st fri
76
+ elsif match_repeats_altmonthly_datemonthly
77
+ found_repeats_altmonthly_datemonthly # repeats altmonthly 22nd
78
+ end
79
+ elsif match_repeats_threemonthly
80
+ if match_repeats_threemonthly_daymonthly
81
+ found_repeats_threemonthly_daymonthly # repeats threemonthly 1st fri
82
+ elsif match_repeats_threemonthly_datemonthly
83
+ found_repeats_threemonthly_datemonthly # repeats threemonthly 22nd
70
84
  end
85
+ end
71
86
 
72
87
  elsif match_for_x
73
- if match_for_x_days then found_for_x_days # for 10 days
74
- elsif match_for_x_weeks then found_for_x_weeks # for 10 weeks
75
- elsif match_for_x_months then found_for_x_months # for 10 months
76
- end
88
+ if match_for_x_days
89
+ found_for_x_days # for 10 days
90
+ elsif match_for_x_weeks
91
+ found_for_x_weeks # for 10 weeks
92
+ elsif match_for_x_months
93
+ found_for_x_months # for 10 months
94
+ end
77
95
 
78
96
  elsif match_this
79
- if match_this_dayname then found_this_dayname # this fri
80
- elsif match_this_week then found_this_week # this week
81
- elsif match_this_month then found_this_month # this month (implies 9/1 to 9/30)
82
- end # SHOULDN'T "this" HAVE "this weekend" ???
97
+ if match_this_dayname
98
+ found_this_dayname # this fri
99
+ elsif match_this_week
100
+ found_this_week # this week
101
+ elsif match_this_month
102
+ found_this_month # this month (implies 9/1 to 9/30)
103
+ end # SHOULDN'T "this" HAVE "this weekend" ???
83
104
 
84
105
  elsif match_next
85
- if match_next_weekend then found_next_weekend # next weekend --- never hit?
86
- elsif match_next_dayname then found_next_dayname # next tuesday
87
- elsif match_next_x
88
- if match_next_x_days then found_next_x_days # next 5 days --- shouldn't this be a wrapper?
89
- elsif match_next_x_weeks then found_next_x_weeks # next 5 weeks --- shouldn't this be a wrapper?
90
- elsif match_next_x_months then found_next_x_months # next 5 months --- shouldn't this be a wrapper?
91
- elsif match_next_x_years then found_next_x_years # next 5 years --- shouldn't this be a wrapper?
92
- end
93
- elsif match_next_week then found_next_week
94
- elsif match_next_month then found_next_month # next month (implies 10/1 to 10/31)
106
+ if match_next_weekend
107
+ found_next_weekend # next weekend --- never hit?
108
+ elsif match_next_dayname
109
+ found_next_dayname # next tuesday
110
+ elsif match_next_x
111
+ if match_next_x_days
112
+ found_next_x_days # next 5 days --- shouldn't this be a wrapper?
113
+ elsif match_next_x_weeks
114
+ found_next_x_weeks # next 5 weeks --- shouldn't this be a wrapper?
115
+ elsif match_next_x_months
116
+ found_next_x_months # next 5 months --- shouldn't this be a wrapper?
117
+ elsif match_next_x_years
118
+ found_next_x_years # next 5 years --- shouldn't this be a wrapper?
95
119
  end
120
+ elsif match_next_week
121
+ found_next_week
122
+ elsif match_next_month
123
+ found_next_month # next month (implies 10/1 to 10/31)
124
+ end
96
125
 
97
126
  elsif match_week
98
- if match_week_of_date then found_week_of_date # week of 1/2
99
- elsif match_week_through_date then found_week_through_date # week through 1/2 (as in, week ending 1/2)
100
- end
127
+ if match_week_of_date
128
+ found_week_of_date # week of 1/2
129
+ elsif match_week_through_date
130
+ found_week_through_date # week through 1/2 (as in, week ending 1/2)
131
+ end
101
132
 
102
133
  elsif match_x_weeks_from
103
- if match_x_weeks_from_dayname then found_x_weeks_from_dayname # 5 weeks from tuesday
104
- elsif match_x_weeks_from_this_dayname then found_x_weeks_from_this_dayname # 5 weeks from this tuesday
105
- elsif match_x_weeks_from_next_dayname then found_x_weeks_from_next_dayname # 5 weeks from next tuesday
106
- elsif match_x_weeks_from_tomorrow then found_x_weeks_from_tomorrow # 5 weeks from tomorrow
107
- elsif match_x_weeks_from_now then found_x_weeks_from_now # 5 weeks from now
108
- elsif match_x_weeks_from_yesterday then found_x_weeks_from_yesterday # 5 weeks from yesterday
109
- end
134
+ if match_x_weeks_from_dayname
135
+ found_x_weeks_from_dayname # 5 weeks from tuesday
136
+ elsif match_x_weeks_from_this_dayname
137
+ found_x_weeks_from_this_dayname # 5 weeks from this tuesday
138
+ elsif match_x_weeks_from_next_dayname
139
+ found_x_weeks_from_next_dayname # 5 weeks from next tuesday
140
+ elsif match_x_weeks_from_tomorrow
141
+ found_x_weeks_from_tomorrow # 5 weeks from tomorrow
142
+ elsif match_x_weeks_from_now
143
+ found_x_weeks_from_now # 5 weeks from now
144
+ elsif match_x_weeks_from_yesterday
145
+ found_x_weeks_from_yesterday # 5 weeks from yesterday
146
+ end
110
147
 
111
148
  elsif match_x_months_from
112
- if match_x_months_from_dayname then found_x_months_from_dayname # 2 months from wed
113
- elsif match_x_months_from_this_dayname then found_x_months_from_this_dayname # 2 months from this wed
114
- elsif match_x_months_from_next_dayname then found_x_months_from_next_dayname # 2 months from next wed
115
- elsif match_x_months_from_tomorrow then found_x_months_from_tomorrow # 2 months from tomorrow
116
- elsif match_x_months_from_now then found_x_months_from_now # 2 months from now
117
- elsif match_x_months_from_yesterday then found_x_months_from_yesterday # 2 months from yesterday
118
- end
149
+ if match_x_months_from_dayname
150
+ found_x_months_from_dayname # 2 months from wed
151
+ elsif match_x_months_from_this_dayname
152
+ found_x_months_from_this_dayname # 2 months from this wed
153
+ elsif match_x_months_from_next_dayname
154
+ found_x_months_from_next_dayname # 2 months from next wed
155
+ elsif match_x_months_from_tomorrow
156
+ found_x_months_from_tomorrow # 2 months from tomorrow
157
+ elsif match_x_months_from_now
158
+ found_x_months_from_now # 2 months from now
159
+ elsif match_x_months_from_yesterday
160
+ found_x_months_from_yesterday # 2 months from yesterday
161
+ end
119
162
 
120
163
  elsif match_x_days_from
121
- if match_x_days_from_now then found_x_days_from_now # 5 days from now
122
- elsif match_x_days_from_dayname then found_x_days_from_dayname # 5 days from monday
123
- end
164
+ if match_x_days_from_now
165
+ found_x_days_from_now # 5 days from now
166
+ elsif match_x_days_from_dayname
167
+ found_x_days_from_dayname # 5 days from monday
168
+ end
124
169
 
125
170
  elsif match_x_dayname_from
126
- if match_x_dayname_from_now then found_x_dayname_from_now # 2 fridays from now
127
- elsif match_x_dayname_from_tomorrow then found_x_dayname_from_tomorrow # 2 fridays from tomorrow
128
- elsif match_x_dayname_from_yesterday then found_x_dayname_from_yesterday # 2 fridays from yesterday
129
- elsif match_x_dayname_from_this then found_x_dayname_from_this # 2 fridays from this one
130
- elsif match_x_dayname_from_next then found_x_dayname_from_next # 2 fridays from next friday
131
- end
132
-
133
- elsif match_x_minutes_from_now then found_x_minutes_from_now # 5 minutes from now
134
- elsif match_x_hours_from_now then found_x_hours_from_now # 5 hours from now
171
+ if match_x_dayname_from_now
172
+ found_x_dayname_from_now # 2 fridays from now
173
+ elsif match_x_dayname_from_tomorrow
174
+ found_x_dayname_from_tomorrow # 2 fridays from tomorrow
175
+ elsif match_x_dayname_from_yesterday
176
+ found_x_dayname_from_yesterday # 2 fridays from yesterday
177
+ elsif match_x_dayname_from_this
178
+ found_x_dayname_from_this # 2 fridays from this one
179
+ elsif match_x_dayname_from_next
180
+ found_x_dayname_from_next # 2 fridays from next friday
181
+ end
182
+
183
+ elsif match_x_minutes_from_now
184
+ found_x_minutes_from_now # 5 minutes from now
185
+ elsif match_x_hours_from_now
186
+ found_x_hours_from_now # 5 hours from now
135
187
 
136
188
  elsif match_ordinal_dayname
137
- if match_ordinal_dayname_this_month then found_ordinal_dayname_this_month # 2nd friday this month
138
- elsif match_ordinal_dayname_next_month then found_ordinal_dayname_next_month # 2nd friday next month
139
- elsif match_ordinal_dayname_monthname then found_ordinal_dayname_monthname # 2nd friday december
140
- end
141
-
142
- elsif match_ordinal_this_month then found_ordinal_this_month # 28th this month
143
- elsif match_ordinal_next_month then found_ordinal_next_month # 28th next month
189
+ if match_ordinal_dayname_this_month
190
+ found_ordinal_dayname_this_month # 2nd friday this month
191
+ elsif match_ordinal_dayname_next_month
192
+ found_ordinal_dayname_next_month # 2nd friday next month
193
+ elsif match_ordinal_dayname_monthname
194
+ found_ordinal_dayname_monthname # 2nd friday december
195
+ end
196
+
197
+ elsif match_ordinal_this_month
198
+ found_ordinal_this_month # 28th this month
199
+ elsif match_ordinal_next_month
200
+ found_ordinal_next_month # 28th next month
144
201
 
145
202
  elsif match_first_day
146
- if match_first_day_this_month then found_first_day_this_month # first day this month
147
- elsif match_first_day_next_month then found_first_day_next_month # first day next month
148
- elsif match_first_day_monthname then found_first_day_monthname # first day january (well this is stupid, "first day of january" gets preprocessed into "1/1", so what is the point of this?)
149
- end
203
+ if match_first_day_this_month
204
+ found_first_day_this_month # first day this month
205
+ elsif match_first_day_next_month
206
+ found_first_day_next_month # first day next month
207
+ elsif match_first_day_monthname
208
+ found_first_day_monthname # first day january (well this is stupid, "first day of january" gets preprocessed into "1/1", so what is the point of this?)
209
+ end
150
210
 
151
211
  elsif match_last_day
152
- if match_last_day_this_month then found_last_day_this_month # last day this month
153
- elsif match_last_day_next_month then found_last_day_next_month # last day next month
154
- elsif match_last_day_monthname then found_last_day_monthname # last day november
155
- end
212
+ if match_last_day_this_month
213
+ found_last_day_this_month # last day this month
214
+ elsif match_last_day_next_month
215
+ found_last_day_next_month # last day next month
216
+ elsif match_last_day_monthname
217
+ found_last_day_monthname # last day november
218
+ end
156
219
 
157
220
  elsif match_at
158
- if match_at_time
159
- if match_at_time_through_time then found_at_time_through_time # at 2 through 5pm
160
- else found_at_time # at 2
161
- end
221
+ if match_at_time
222
+ if match_at_time_through_time
223
+ found_at_time_through_time # at 2 through 5pm
224
+ else
225
+ found_at_time # at 2
162
226
  end
227
+ end
163
228
 
164
- elsif match_all_day then found_all_day # all day
229
+ elsif match_all_day
230
+ found_all_day # all day
165
231
 
166
232
  elsif match_tomorrow
167
- if match_tomorrow_through
168
- if match_tomorrow_through_dayname then found_tomorrow_through_dayname # tomorrow through friday
169
- elsif match_tomorrow_through_date then found_tomorrow_through_date # tomorrow through august 20th
170
- end
171
- else found_tomorrow # tomorrow
233
+ if match_tomorrow_through
234
+ if match_tomorrow_through_dayname
235
+ found_tomorrow_through_dayname # tomorrow through friday
236
+ elsif match_tomorrow_through_date
237
+ found_tomorrow_through_date # tomorrow through august 20th
172
238
  end
239
+ else
240
+ found_tomorrow # tomorrow
241
+ end
173
242
 
174
243
  elsif match_now
175
- if match_now_through
176
- if match_now_through_dayname then found_now_through_dayname # today through friday
177
- elsif match_now_through_following_dayname then found_now_through_following_dayname # REDUNDANT, PREPROCESS THIS OUT
178
- elsif match_now_through_date then found_now_through_date # today through 10/1
179
- elsif match_now_through_tomorrow then found_now_through_tomorrow # today through tomorrow
180
- elsif match_now_through_next_dayname then found_now_through_next_dayname # today through next friday
181
- end
182
- else found_now # today
244
+ if match_now_through
245
+ if match_now_through_dayname
246
+ found_now_through_dayname # today through friday
247
+ elsif match_now_through_following_dayname
248
+ found_now_through_following_dayname # REDUNDANT, PREPROCESS THIS OUT
249
+ elsif match_now_through_date
250
+ found_now_through_date # today through 10/1
251
+ elsif match_now_through_tomorrow
252
+ found_now_through_tomorrow # today through tomorrow
253
+ elsif match_now_through_next_dayname
254
+ found_now_through_next_dayname # today through next friday
183
255
  end
256
+ else
257
+ found_now # today
258
+ end
184
259
 
185
260
  elsif match_dayname
186
- if match_dayname_the_ordinal then found_dayname_the_ordinal # monday the 21st
187
- elsif match_dayname_x_weeks_from_next then found_dayname_x_weeks_from_next # monday 2 weeks from next
188
- elsif match_dayname_x_weeks_from_this then found_dayname_x_weeks_from_this # monday 2 weeks from this
189
- else found_dayname # monday (also monday tuesday wed...)
190
- end
191
-
192
- elsif match_through_monthname then found_through_monthname # through december (implies through 11/30)
193
- elsif match_monthname then found_monthname # december (implies 12/1 to 12/31)
261
+ if match_dayname_the_ordinal
262
+ found_dayname_the_ordinal # monday the 21st
263
+ elsif match_dayname_x_weeks_from_next
264
+ found_dayname_x_weeks_from_next # monday 2 weeks from next
265
+ elsif match_dayname_x_weeks_from_this
266
+ found_dayname_x_weeks_from_this # monday 2 weeks from this
267
+ else
268
+ found_dayname # monday (also monday tuesday wed...)
269
+ end
270
+
271
+ elsif match_through_monthname
272
+ found_through_monthname # through december (implies through 11/30)
273
+ elsif match_monthname
274
+ found_monthname # december (implies 12/1 to 12/31)
194
275
 
195
276
  # 5th constructor
196
- elsif match_start then found_start
197
- elsif match_through then found_through
198
-
199
- elsif match_time # match time second to last
200
- if match_time_through_time then found_time_through_time # 10 to 4
201
- else found_time # 10
202
- end
203
-
204
- elsif match_date # match date last
205
- if match_date_through_date then found_date_through_date # 5th through the 16th
206
- else found_date # 5th
207
- end
277
+ elsif match_start
278
+ found_start
279
+ elsif match_through
280
+ found_through
281
+
282
+ elsif match_time # match time second to last
283
+ if match_time_through_time
284
+ found_time_through_time # 10 to 4
285
+ else
286
+ found_time # 10
287
+ end
288
+
289
+ elsif match_date # match date last
290
+ if match_date_through_date
291
+ found_date_through_date # 5th through the 16th
292
+ else
293
+ found_date # 5th
294
+ end
208
295
  end
209
296
  end # end def big_if_on_current_word
210
297
 
211
298
  def match_every
212
- @components[@pos]=="every"
299
+ @components[@pos] == 'every'
213
300
  end
214
301
 
215
302
  def match_every_dayname
216
- @day_index = ZDate.days_of_week.index(@components[@pos+1]) # if "every [day]"
303
+ @day_index = ZDate.days_of_week.index(@components[@pos + 1]) # if "every [day]"
217
304
  end
218
305
 
219
306
  def found_every_dayname
220
- day_array=[@day_index]
307
+ day_array = [@day_index]
221
308
  j = 2
222
- while @components[@pos+j] && ZDate.days_of_week.index(@components[@pos+j]) # if "every mon tue wed"
223
- day_array << ZDate.days_of_week.index(@components[@pos+j])
309
+ while @components[@pos + j] && ZDate.days_of_week.index(@components[@pos + j]) # if "every mon tue wed"
310
+ day_array << ZDate.days_of_week.index(@components[@pos + j])
224
311
  j += 1
225
312
  end
226
- @constructs << RecurrenceConstruct.new(:repeats => :weekly, :repeats_on => day_array, :comp_start => @pos, :comp_end => @pos += (j - 1), :found_in => __method__)
313
+ @constructs << RecurrenceConstruct.new(repeats: :weekly, repeats_on: day_array, comp_start: @pos, comp_end: @pos += (j - 1), found_in: __method__)
227
314
  end
228
315
 
229
316
  def match_every_day
230
- @components[@pos+1] == "day"
317
+ @components[@pos + 1] == 'day'
231
318
  end
232
319
 
233
320
  def found_every_day
234
- @constructs << RecurrenceConstruct.new(:repeats => :daily, :comp_start => @pos, :comp_end => @pos += 1, :found_in => __method__)
321
+ @constructs << RecurrenceConstruct.new(repeats: :daily, comp_start: @pos, comp_end: @pos += 1, found_in: __method__)
235
322
  end
236
323
 
237
324
  def match_every_other
238
- @components[@pos+1] =~ /other|2nd/
325
+ @components[@pos + 1] =~ /other|2nd/
239
326
  end
240
327
 
241
328
  def match_every_other_dayname
242
- @day_index = ZDate.days_of_week.index(@components[@pos+2]) # if "every other mon"
329
+ @day_index = ZDate.days_of_week.index(@components[@pos + 2]) # if "every other mon"
243
330
  end
244
331
 
245
332
  def found_every_other_dayname
246
333
  day_array = [@day_index]
247
334
  j = 3
248
- while @components[@pos+j] && ZDate.days_of_week.index(@components[@pos+j]) #if "every other mon tue wed
249
- day_array << ZDate.days_of_week.index(@components[@pos+j])
335
+ while @components[@pos + j] && ZDate.days_of_week.index(@components[@pos + j]) # if "every other mon tue wed
336
+ day_array << ZDate.days_of_week.index(@components[@pos + j])
250
337
  j += 1
251
338
  end
252
- @constructs << RecurrenceConstruct.new(:repeats => :altweekly, :repeats_on => day_array, :comp_start => @pos, :comp_end => @pos += (j - 1), :found_in => __method__)
339
+ @constructs << RecurrenceConstruct.new(repeats: :altweekly, repeats_on: day_array, comp_start: @pos, comp_end: @pos += (j - 1), found_in: __method__)
253
340
  end
254
341
 
255
342
  def match_every_other_day
256
- @components[@pos+2] == "day" ## if "every other day"
343
+ @components[@pos + 2] == 'day' # if "every other day"
257
344
  end
258
345
 
259
346
  def found_every_other_day
260
- @constructs << RecurrenceConstruct.new(:repeats => :altdaily, :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
347
+ @constructs << RecurrenceConstruct.new(repeats: :altdaily, comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
261
348
  end
262
349
 
263
350
  def match_every_3rd
264
- @components[@pos+1] == "3rd"
351
+ @components[@pos + 1] == '3rd'
265
352
  end
266
353
 
267
354
  def match_every_3rd_dayname
268
- @day_index = ZDate.days_of_week.index(@components[@pos+2]) # if "every 3rd tue"
355
+ @day_index = ZDate.days_of_week.index(@components[@pos + 2]) # if "every 3rd tue"
269
356
  end
270
357
 
271
358
  def found_every_3rd_dayname
272
359
  day_array = [@day_index]
273
360
  j = 3
274
- while @components[@pos+j] && ZDate.days_of_week.index(@components[@pos+j]) #if "every 3rd tue wed thu
275
- day_array << ZDate.days_of_week.index(@components[@pos+j])
361
+ while @components[@pos + j] && ZDate.days_of_week.index(@components[@pos + j]) # if "every 3rd tue wed thu
362
+ day_array << ZDate.days_of_week.index(@components[@pos + j])
276
363
  j += 1
277
364
  end
278
- @constructs << RecurrenceConstruct.new(:repeats => :threeweekly, :repeats_on => day_array, :comp_start => @pos, :comp_end => @pos += (j - 1), :found_in => __method__)
365
+ @constructs << RecurrenceConstruct.new(repeats: :threeweekly, repeats_on: day_array, comp_start: @pos, comp_end: @pos += (j - 1), found_in: __method__)
279
366
  end
280
367
 
281
368
  def match_every_3rd_day
282
- @components[@pos+2] == "day" ## if "every 3rd day"
369
+ @components[@pos + 2] == 'day' # if "every 3rd day"
283
370
  end
284
371
 
285
372
  def found_every_3rd_day
286
- @constructs << RecurrenceConstruct.new(:repeats => :threedaily, :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
373
+ @constructs << RecurrenceConstruct.new(repeats: :threedaily, comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
287
374
  end
288
375
 
289
376
  def match_repeats
290
- @components[@pos] == "repeats"
377
+ @components[@pos] == 'repeats'
291
378
  end
292
379
 
293
380
  def match_repeats_daily
294
- @components[@pos+1] == "daily"
381
+ @components[@pos + 1] == 'daily'
295
382
  end
296
383
 
297
384
  def found_repeats_daily
298
- @constructs << RecurrenceConstruct.new(:repeats => :daily, :comp_start => @pos, :comp_end => @pos += 1, :found_in => __method__)
385
+ @constructs << RecurrenceConstruct.new(repeats: :daily, comp_start: @pos, comp_end: @pos += 1, found_in: __method__)
299
386
  end
300
387
 
301
388
  def match_repeats_altdaily
302
- @components[@pos+1] == "altdaily"
389
+ @components[@pos + 1] == 'altdaily'
303
390
  end
304
391
 
305
392
  def found_repeats_altdaily
306
- @constructs << RecurrenceConstruct.new(:repeats => :altdaily, :comp_start => @pos, :comp_end => @pos += 1, :found_in => __method__)
393
+ @constructs << RecurrenceConstruct.new(repeats: :altdaily, comp_start: @pos, comp_end: @pos += 1, found_in: __method__)
307
394
  end
308
395
 
309
396
  def match_repeats_weekly_vague
310
- @components[@pos+1] == "weekly"
397
+ @components[@pos + 1] == 'weekly'
311
398
  end
312
399
 
313
400
  def found_repeats_weekly_vague
314
- @constructs << RecurrenceConstruct.new(:repeats => :weekly, :comp_start => @pos, :comp_end => @pos += 1, :found_in => __method__)
401
+ @constructs << RecurrenceConstruct.new(repeats: :weekly, comp_start: @pos, comp_end: @pos += 1, found_in: __method__)
315
402
  end
316
403
 
317
404
  def match_repeats_altweekly_vague
318
- @components[@pos+1] == "altweekly"
405
+ @components[@pos + 1] == 'altweekly'
319
406
  end
320
407
 
321
408
  def found_repeats_altweekly_vague
322
- @constructs << RecurrenceConstruct.new(:repeats => :altweekly, :comp_start => @pos, :comp_end => @pos += 1, :found_in => __method__)
409
+ @constructs << RecurrenceConstruct.new(repeats: :altweekly, comp_start: @pos, comp_end: @pos += 1, found_in: __method__)
323
410
  end
324
411
 
325
412
  def match_repeats_monthly
326
- @components[@pos+1] == "monthly"
413
+ @components[@pos + 1] == 'monthly'
327
414
  end
328
415
 
329
416
  def match_repeats_daymonthly
330
- @components[@pos+2] && @components[@pos+3] && (@week_num = @components[@pos+2].to_i) && @week_num > 0 && @week_num <= 5 && (@day_index = ZDate.days_of_week.index(@components[@pos+3])) # "repeats monthly 2nd wed"
417
+ @components[@pos + 2] && @components[@pos + 3] && (@week_num = @components[@pos + 2].to_i) && @week_num > 0 && @week_num <= 5 && (@day_index = ZDate.days_of_week.index(@components[@pos + 3])) # "repeats monthly 2nd wed"
331
418
  end
332
419
 
333
420
  def found_repeats_daymonthly
334
421
  rep_array = [[@week_num, @day_index]] # That is NOT a typo, not sure what I meant by that! maybe the nested array
335
422
  j = 4
336
- while @components[@pos+j] && @components[@pos+j+1] && (@week_num = @components[@pos+j].to_i) && @week_num > 0 && @week_num <= 5 && (@day_index = ZDate.days_of_week.index(@components[@pos+j+1]))
423
+ while @components[@pos + j] && @components[@pos + j + 1] && (@week_num = @components[@pos + j].to_i) && @week_num > 0 && @week_num <= 5 && (@day_index = ZDate.days_of_week.index(@components[@pos + j + 1]))
337
424
  rep_array << [@week_num, @day_index]
338
425
  j += 2
339
426
  end
340
- @constructs << RecurrenceConstruct.new(:repeats => :daymonthly, :repeats_on => rep_array, :comp_start => @pos, :comp_end => @pos += (j - 1), :found_in => __method__)
427
+ @constructs << RecurrenceConstruct.new(repeats: :daymonthly, repeats_on: rep_array, comp_start: @pos, comp_end: @pos += (j - 1), found_in: __method__)
341
428
  end
342
429
 
343
430
  def match_repeats_datemonthly
344
- @components[@pos+2] && ConstructFinder.ordinal_only?(@components[@pos+2]) && @date_array = [@components[@pos+2].to_i] # repeats monthly 22nd
431
+ @components[@pos + 2] && ConstructFinder.ordinal_only?(@components[@pos + 2]) && @date_array = [@components[@pos + 2].to_i] # repeats monthly 22nd
345
432
  end
346
433
 
347
434
  def found_repeats_datemonthly
348
435
  j = 3
349
- while @components[@pos+j] && ConstructFinder.ordinal_only?(@components[@pos+j])
350
- @date_array << @components[@pos+j].to_i
436
+ while @components[@pos + j] && ConstructFinder.ordinal_only?(@components[@pos + j])
437
+ @date_array << @components[@pos + j].to_i
351
438
  j += 1
352
439
  end
353
- @constructs << RecurrenceConstruct.new(:repeats => :datemonthly, :repeats_on => @date_array, :comp_start => @pos, :comp_end => @pos += (j - 1), :found_in => __method__)
440
+ @constructs << RecurrenceConstruct.new(repeats: :datemonthly, repeats_on: @date_array, comp_start: @pos, comp_end: @pos += (j - 1), found_in: __method__)
354
441
  end
355
442
 
356
443
  def match_repeats_altmonthly
357
- @components[@pos+1] == "altmonthly"
444
+ @components[@pos + 1] == 'altmonthly'
358
445
  end
359
446
 
360
447
  def match_repeats_altmonthly_daymonthly
361
- @components[@pos+2] && @components[@pos+3] && (@week_num = @components[@pos+2].to_i) && @week_num > 0 && @week_num <= 5 && (@day_index = ZDate.days_of_week.index(@components[@pos+3])) # "repeats altmonthly 2nd wed"
448
+ @components[@pos + 2] && @components[@pos + 3] && (@week_num = @components[@pos + 2].to_i) && @week_num > 0 && @week_num <= 5 && (@day_index = ZDate.days_of_week.index(@components[@pos + 3])) # "repeats altmonthly 2nd wed"
362
449
  end
363
450
 
364
451
  def found_repeats_altmonthly_daymonthly
365
452
  rep_array = [[@week_num, @day_index]]
366
453
  j = 4
367
- while @components[@pos+j] && @components[@pos+j+1] && (@week_num = @components[@pos+j].to_i) && @week_num > 0 && @week_num <= 5 && (@day_index = ZDate.days_of_week.index(@components[@pos+j+1]))
454
+ while @components[@pos + j] && @components[@pos + j + 1] && (@week_num = @components[@pos + j].to_i) && @week_num > 0 && @week_num <= 5 && (@day_index = ZDate.days_of_week.index(@components[@pos + j + 1]))
368
455
  rep_array << [@week_num, @day_index]
369
456
  j += 2
370
457
  end
371
- @constructs << RecurrenceConstruct.new(:repeats => :altdaymonthly, :repeats_on => rep_array, :comp_start => @pos, :comp_end => @pos += (j - 1), :found_in => __method__)
458
+ @constructs << RecurrenceConstruct.new(repeats: :altdaymonthly, repeats_on: rep_array, comp_start: @pos, comp_end: @pos += (j - 1), found_in: __method__)
372
459
  end
373
460
 
374
461
  def match_repeats_altmonthly_datemonthly
375
- @components[@pos+2] && ConstructFinder.ordinal_only?(@components[@pos+2]) && @date_array = [@components[@pos+2].to_i] # repeats altmonthly 22nd
462
+ @components[@pos + 2] && ConstructFinder.ordinal_only?(@components[@pos + 2]) && @date_array = [@components[@pos + 2].to_i] # repeats altmonthly 22nd
376
463
  end
377
464
 
378
465
  def found_repeats_altmonthly_datemonthly
379
466
  j = 3
380
- while @components[@pos+j] && ConstructFinder.ordinal_only?(@components[@pos+j])
381
- @date_array << @components[@pos+j].to_i
467
+ while @components[@pos + j] && ConstructFinder.ordinal_only?(@components[@pos + j])
468
+ @date_array << @components[@pos + j].to_i
382
469
  j += 1
383
470
  end
384
- @constructs << RecurrenceConstruct.new(:repeats => :altdatemonthly, :repeats_on => @date_array, :comp_start => @pos, :comp_end => @pos += (j - 1), :found_in => __method__)
471
+ @constructs << RecurrenceConstruct.new(repeats: :altdatemonthly, repeats_on: @date_array, comp_start: @pos, comp_end: @pos += (j - 1), found_in: __method__)
385
472
  end
386
473
 
387
474
  def match_repeats_threemonthly
388
- @components[@pos+1] == "threemonthly"
475
+ @components[@pos + 1] == 'threemonthly'
389
476
  end
390
477
 
391
478
  def match_repeats_threemonthly_daymonthly
392
- @components[@pos+2] && @components[@pos+3] && (@week_num = @components[@pos+2].to_i) && @week_num > 0 && @week_num <= 5 && (@day_index = ZDate.days_of_week.index(@components[@pos+3])) # "repeats threemonthly 2nd wed"
479
+ @components[@pos + 2] && @components[@pos + 3] && (@week_num = @components[@pos + 2].to_i) && @week_num > 0 && @week_num <= 5 && (@day_index = ZDate.days_of_week.index(@components[@pos + 3])) # "repeats threemonthly 2nd wed"
393
480
  end
394
481
 
395
482
  def found_repeats_threemonthly_daymonthly
396
483
  rep_array = [[@week_num, @day_index]] # That is NOT a typo
397
484
  j = 4
398
- while @components[@pos+j] && @components[@pos+j+1] && (@week_num = @components[@pos+j].to_i) && @week_num > 0 && @week_num <= 5 && (@day_index = ZDate.days_of_week.index(@components[@pos+j+1]))
485
+ while @components[@pos + j] && @components[@pos + j + 1] && (@week_num = @components[@pos + j].to_i) && @week_num > 0 && @week_num <= 5 && (@day_index = ZDate.days_of_week.index(@components[@pos + j + 1]))
399
486
  rep_array << [@week_num, @day_index]
400
487
  j += 2
401
488
  end
402
- @constructs << RecurrenceConstruct.new(:repeats => :threedaymonthly, :repeats_on => rep_array, :comp_start => @pos, :comp_end => @pos += (j - 1), :found_in => __method__)
489
+ @constructs << RecurrenceConstruct.new(repeats: :threedaymonthly, repeats_on: rep_array, comp_start: @pos, comp_end: @pos += (j - 1), found_in: __method__)
403
490
  end
404
491
 
405
492
  def match_repeats_threemonthly_datemonthly
406
- @components[@pos+2] && ConstructFinder.ordinal_only?(@components[@pos+2]) && @date_array = [@components[@pos+2].to_i] # repeats threemonthly 22nd
493
+ @components[@pos + 2] && ConstructFinder.ordinal_only?(@components[@pos + 2]) && @date_array = [@components[@pos + 2].to_i] # repeats threemonthly 22nd
407
494
  end
408
495
 
409
496
  def found_repeats_threemonthly_datemonthly
410
497
  j = 3
411
- while @components[@pos+j] && ConstructFinder.ordinal_only?(@components[@pos+j])
412
- @date_array << @components[@pos+j].to_i
498
+ while @components[@pos + j] && ConstructFinder.ordinal_only?(@components[@pos + j])
499
+ @date_array << @components[@pos + j].to_i
413
500
  j += 1
414
501
  end
415
- @constructs << RecurrenceConstruct.new(:repeats => :threedatemonthly, :repeats_on => @date_array, :comp_start => @pos, :comp_end => @pos += (j - 1), :found_in => __method__)
502
+ @constructs << RecurrenceConstruct.new(repeats: :threedatemonthly, repeats_on: @date_array, comp_start: @pos, comp_end: @pos += (j - 1), found_in: __method__)
416
503
  end
417
504
 
418
505
  def match_for_x
419
- @components[@pos]=="for" && ConstructFinder.digits_only?(@components[@pos+1]) && @length = @components[@pos+1].to_i
506
+ @components[@pos] == 'for' && ConstructFinder.digits_only?(@components[@pos + 1]) && @length = @components[@pos + 1].to_i
420
507
  end
421
508
 
422
509
  def match_for_x_days
423
- @components[@pos+2] =~ /days?/
510
+ @components[@pos + 2] =~ /days?/
424
511
  end
425
512
 
426
513
  def found_for_x_days
427
- @constructs << WrapperConstruct.new(:wrapper_type => 2, :wrapper_length => @length, :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
514
+ @constructs << WrapperConstruct.new(wrapper_type: 2, wrapper_length: @length, comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
428
515
  end
429
516
 
430
517
  def match_for_x_weeks
431
- @components[@pos+2] =~ /weeks?/
518
+ @components[@pos + 2] =~ /weeks?/
432
519
  end
433
520
 
434
521
  def found_for_x_weeks
435
- @constructs << WrapperConstruct.new(:wrapper_type => 3, :wrapper_length => @length, :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
522
+ @constructs << WrapperConstruct.new(wrapper_type: 3, wrapper_length: @length, comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
436
523
  end
437
524
 
438
525
  def match_for_x_months
439
- @components[@pos+2] =~ /months?/
526
+ @components[@pos + 2] =~ /months?/
440
527
  end
441
528
 
442
529
  def found_for_x_months
443
- @constructs << WrapperConstruct.new(:wrapper_type => 4, :wrapper_length => @length, :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
530
+ @constructs << WrapperConstruct.new(wrapper_type: 4, wrapper_length: @length, comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
444
531
  end
445
532
 
446
533
  def match_this
447
- @components[@pos]=="this"
534
+ @components[@pos] == 'this'
448
535
  end
449
536
 
450
537
  def match_this_dayname
451
- @day_index = ZDate.days_of_week.index(@components[@pos+1])
538
+ @day_index = ZDate.days_of_week.index(@components[@pos + 1])
452
539
  end
453
540
 
454
541
  def found_this_dayname
455
542
  day_to_add = @curdate.this(@day_index)
456
- @constructs << DateConstruct.new(:date => day_to_add, :comp_start => @pos, :comp_end => @pos += 1, :found_in => __method__)
457
- while @components[@pos+1] && @day_index = ZDate.days_of_week.index(@components[@pos+1])
543
+ @constructs << DateConstruct.new(date: day_to_add, comp_start: @pos, comp_end: @pos += 1, found_in: __method__)
544
+ while @components[@pos + 1] && @day_index = ZDate.days_of_week.index(@components[@pos + 1])
458
545
  # note @pos gets incremented on each pass
459
- @constructs << DateConstruct.new(:date => day_to_add = day_to_add.this(@day_index), :comp_start => @pos + 1, :comp_end => @pos += 1, :found_in => __method__)
546
+ @constructs << DateConstruct.new(date: day_to_add = day_to_add.this(@day_index), comp_start: @pos + 1, comp_end: @pos += 1, found_in: __method__)
460
547
  end
461
548
  end
462
549
 
463
550
  def match_this_week
464
- @components[@pos+1] =~ /weeks?/
551
+ @components[@pos + 1] =~ /weeks?/
465
552
  end
466
553
 
467
554
  def found_this_week
468
- @constructs << DateSpanConstruct.new(:start_date => @curdate, :end_date => @curdate.add_days(7), :comp_start => @pos, :comp_end => @pos += 1, :found_in => __method__)
555
+ @constructs << DateSpanConstruct.new(start_date: @curdate, end_date: @curdate.add_days(7), comp_start: @pos, comp_end: @pos += 1, found_in: __method__)
469
556
  end
470
557
 
471
558
  def match_this_month
472
- @components[@pos+1] =~ /months?/
559
+ @components[@pos + 1] =~ /months?/
473
560
  end
474
561
 
475
562
  def found_this_month
476
- @constructs << DateSpanConstruct.new(:start_date => @curdate, :end_date => @curdate.end_of_month, :comp_start => @pos, :comp_end => @pos += 1, :found_in => __method__)
563
+ @constructs << DateSpanConstruct.new(start_date: @curdate, end_date: @curdate.end_of_month, comp_start: @pos, comp_end: @pos += 1, found_in: __method__)
477
564
  end
478
565
 
479
-
480
566
  def match_next
481
- @components[@pos]=="next"
567
+ @components[@pos] == 'next'
482
568
  end
483
569
 
484
570
  def match_next_weekend
485
- @components[@pos+1]=="weekend" ## "next weekend"
571
+ @components[@pos + 1] == 'weekend' # "next weekend"
486
572
  end
487
573
 
488
574
  def found_next_weekend
489
- dsc = DateSpanConstruct.new(:start_date => @curdate.next(5), :comp_start => @pos, :comp_end => @pos += 1, :found_in => __method__)
575
+ dsc = DateSpanConstruct.new(start_date: @curdate.next(5), comp_start: @pos, comp_end: @pos += 1, found_in: __method__)
490
576
  dsc.end_date = dsc.start_date.add_days(1)
491
577
  @constructs << dsc
492
578
  end
493
579
 
494
580
  def match_next_dayname
495
- @day_index = ZDate.days_of_week.index(@components[@pos+1]) ## if "next [day]"
581
+ @day_index = ZDate.days_of_week.index(@components[@pos + 1]) # if "next [day]"
496
582
  end
497
583
 
498
584
  def found_next_dayname
499
585
  day_to_add = @curdate.next(@day_index)
500
- @constructs << DateConstruct.new(:date => day_to_add, :comp_start => @pos, :comp_end => @pos += 1, :found_in => __method__)
501
- while @components[@pos+1] && @day_index = ZDate.days_of_week.index(@components[@pos+1])
586
+ @constructs << DateConstruct.new(date: day_to_add, comp_start: @pos, comp_end: @pos += 1, found_in: __method__)
587
+ while @components[@pos + 1] && @day_index = ZDate.days_of_week.index(@components[@pos + 1])
502
588
  # note @pos gets incremented on each pass
503
- @constructs << DateConstruct.new(:date => day_to_add = day_to_add.this(@day_index), :comp_start => @pos + 1, :comp_end => @pos += 1, :found_in => __method__)
589
+ @constructs << DateConstruct.new(date: day_to_add = day_to_add.this(@day_index), comp_start: @pos + 1, comp_end: @pos += 1, found_in: __method__)
504
590
  end
505
591
  end
506
592
 
507
593
  def match_next_x
508
- @components[@pos+1] && ConstructFinder.digits_only?(@components[@pos+1]) && @length = @components[@pos+1].to_i
594
+ @components[@pos + 1] && ConstructFinder.digits_only?(@components[@pos + 1]) && @length = @components[@pos + 1].to_i
509
595
  end
510
596
 
511
597
  def match_next_x_days
512
- @components[@pos+2] =~ /days?/ ## "next x days"
598
+ @components[@pos + 2] =~ /days?/ # "next x days"
513
599
  end
514
600
 
515
601
  def found_next_x_days
516
- @constructs << DateSpanConstruct.new(:start_date => @curdate, :end_date => @curdate.add_days(@length), :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
602
+ @constructs << DateSpanConstruct.new(start_date: @curdate, end_date: @curdate.add_days(@length), comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
517
603
  end
518
604
 
519
605
  def match_next_x_weeks
520
- @components[@pos+2] =~ /weeks?/ ## "next x weeks"
606
+ @components[@pos + 2] =~ /weeks?/ # "next x weeks"
521
607
  end
522
608
 
523
609
  def found_next_x_weeks
524
- @constructs << DateSpanConstruct.new(:start_date => @curdate, :end_date => @curdate.add_weeks(@length), :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
610
+ @constructs << DateSpanConstruct.new(start_date: @curdate, end_date: @curdate.add_weeks(@length), comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
525
611
  end
526
612
 
527
613
  def match_next_x_months
528
- @components[@pos+2] =~ /months?/ ## "next x months"
614
+ @components[@pos + 2] =~ /months?/ # "next x months"
529
615
  end
530
616
 
531
617
  def found_next_x_months
532
- @constructs << DateSpanConstruct.new(:start_date => @curdate, :end_date => @curdate.add_months(@length), :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
618
+ @constructs << DateSpanConstruct.new(start_date: @curdate, end_date: @curdate.add_months(@length), comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
533
619
  end
534
620
 
535
621
  def match_next_x_years
536
- @components[@pos+2] =~ /years?/ ## "next x years"
622
+ @components[@pos + 2] =~ /years?/ # "next x years"
537
623
  end
538
624
 
539
625
  def found_next_x_years
540
- @constructs << DateSpanConstruct.new(:start_date => @curdate, :end_date => @curdate.add_years(@length), :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
626
+ @constructs << DateSpanConstruct.new(start_date: @curdate, end_date: @curdate.add_years(@length), comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
541
627
  end
542
628
 
543
629
  def match_next_week
544
- @components[@pos+1] =~ /weeks?/
630
+ @components[@pos + 1] =~ /weeks?/
545
631
  end
546
632
 
547
633
  def found_next_week
548
634
  sd = @curdate.add_days(7)
549
635
  ed = sd.add_days(7)
550
- @constructs << DateSpanConstruct.new(:start_date => sd, :end_date => ed, :comp_start => @pos, :comp_end => @pos += 1, :found_in => __method__)
636
+ @constructs << DateSpanConstruct.new(start_date: sd, end_date: ed, comp_start: @pos, comp_end: @pos += 1, found_in: __method__)
551
637
  end
552
638
 
553
639
  def match_next_month
554
640
  # note it is important that all other uses of "next month" come after indicating words such as "every day next month"; otherwise they will be converted here
555
- @components[@pos+1] =~ /months?/
641
+ @components[@pos + 1] =~ /months?/
556
642
  end
557
643
 
558
644
  def found_next_month
559
645
  sd = @curdate.add_months(1).beginning_of_month
560
646
  ed = sd.end_of_month
561
- @constructs << DateSpanConstruct.new(:start_date => sd, :end_date => ed, :comp_start => @pos, :comp_end => @pos += 1, :found_in => __method__)
647
+ @constructs << DateSpanConstruct.new(start_date: sd, end_date: ed, comp_start: @pos, comp_end: @pos += 1, found_in: __method__)
562
648
  end
563
649
 
564
650
  def match_week
565
- @components[@pos] == "week"
651
+ @components[@pos] == 'week'
566
652
  end
567
653
 
568
654
  def match_week_of_date
569
- @components[@pos+1] == "of" && @date1 = ZDate.interpret(@components[@pos+2], @curdate)
655
+ @components[@pos + 1] == 'of' && @date1 = ZDate.interpret(@components[@pos + 2], @curdate)
570
656
  end
571
657
 
572
658
  def found_week_of_date
573
- @constructs << DateSpanConstruct.new(:start_date => @date1, :end_date => @date1.add_days(7), :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
659
+ @constructs << DateSpanConstruct.new(start_date: @date1, end_date: @date1.add_days(7), comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
574
660
  end
575
661
 
576
662
  def match_week_through_date
577
- @components[@pos+1] == "through" && @date1 = ZDate.interpret(@components[@pos+2], @curdate)
663
+ @components[@pos + 1] == 'through' && @date1 = ZDate.interpret(@components[@pos + 2], @curdate)
578
664
  end
579
665
 
580
666
  def found_week_through_date
581
- @constructs << DateSpanConstruct.new(:start_date => @date1.sub_days(7), :end_date => @date1, :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
667
+ @constructs << DateSpanConstruct.new(start_date: @date1.sub_days(7), end_date: @date1, comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
582
668
  end
583
669
 
584
670
  def match_x_weeks_from
585
- ConstructFinder.digits_only?(@components[@pos]) && @components[@pos+1] =~ /^weeks?$/ && @components[@pos+2] == "from" && @length = @components[@pos].to_i # if "x weeks from"
671
+ ConstructFinder.digits_only?(@components[@pos]) && @components[@pos + 1] =~ /^weeks?$/ && @components[@pos + 2] == 'from' && @length = @components[@pos].to_i # if "x weeks from"
586
672
  end
587
673
 
588
674
  def match_x_weeks_from_dayname
589
- @day_index = ZDate.days_of_week.index(@components[@pos+3]) # if "x weeks from monday"
675
+ @day_index = ZDate.days_of_week.index(@components[@pos + 3]) # if "x weeks from monday"
590
676
  end
591
677
 
592
678
  def found_x_weeks_from_dayname
593
- @constructs << DateConstruct.new(:date => @curdate.x_weeks_from_day(@length, @day_index), :comp_start => @pos, :comp_end => @pos += 3, :found_in => __method__)
679
+ @constructs << DateConstruct.new(date: @curdate.x_weeks_from_day(@length, @day_index), comp_start: @pos, comp_end: @pos += 3, found_in: __method__)
594
680
  end
595
681
 
596
682
  # Reduntant, preprocess out!
597
683
  def match_x_weeks_from_this_dayname
598
- @components[@pos+3] == "this" && @day_index = ZDate.days_of_week.index(@components[@pos+4]) # if "x weeks from this monday"
684
+ @components[@pos + 3] == 'this' && @day_index = ZDate.days_of_week.index(@components[@pos + 4]) # if "x weeks from this monday"
599
685
  end
600
686
 
601
687
  # Reduntant, preprocess out!
602
688
  def found_x_weeks_from_this_dayname
603
689
  # this is the exact some construct as found_x_weeks_from_dayname, just position and comp_end has to increment by 1 more; pretty stupid, this should be caught in preprocessing
604
- @constructs << DateConstruct.new(:date => @curdate.x_weeks_from_day(@length, @day_index), :comp_start => @pos, :comp_end => @pos += 4, :found_in => __method__)
690
+ @constructs << DateConstruct.new(date: @curdate.x_weeks_from_day(@length, @day_index), comp_start: @pos, comp_end: @pos += 4, found_in: __method__)
605
691
  end
606
692
 
607
693
  def match_x_weeks_from_next_dayname
608
- @components[@pos+3] == "next" && @day_index = ZDate.days_of_week.index(@components[@pos+4]) # if "x weeks from next monday"
694
+ @components[@pos + 3] == 'next' && @day_index = ZDate.days_of_week.index(@components[@pos + 4]) # if "x weeks from next monday"
609
695
  end
610
696
 
611
697
  def found_x_weeks_from_next_dayname
612
- @constructs << DateConstruct.new(:date => @curdate.x_weeks_from_day(@length + 1, @day_index), :comp_start => @pos, :comp_end => @pos += 4, :found_in => __method__)
698
+ @constructs << DateConstruct.new(date: @curdate.x_weeks_from_day(@length + 1, @day_index), comp_start: @pos, comp_end: @pos += 4, found_in: __method__)
613
699
  end
614
700
 
615
701
  def match_x_weeks_from_tomorrow
616
- @components[@pos+3] == "tomorrow" # if "x weeks from tomorrow"
702
+ @components[@pos + 3] == 'tomorrow' # if "x weeks from tomorrow"
617
703
  end
618
704
 
619
705
  def found_x_weeks_from_tomorrow
620
- @constructs << DateConstruct.new(:date => @curdate.add_days(1).add_weeks(@length), :comp_start => @pos, :comp_end => @pos += 3, :found_in => __method__)
706
+ @constructs << DateConstruct.new(date: @curdate.add_days(1).add_weeks(@length), comp_start: @pos, comp_end: @pos += 3, found_in: __method__)
621
707
  end
622
708
 
623
709
  def match_x_weeks_from_now
624
- @components[@pos+3] =~ /\b(today)|(now)\b/ # if "x weeks from today"
710
+ @components[@pos + 3] =~ /\b(today)|(now)\b/ # if "x weeks from today"
625
711
  end
626
712
 
627
713
  def found_x_weeks_from_now
628
- @constructs << DateConstruct.new(:date => @curdate.x_weeks_from_day(@length, @curdate.dayindex), :comp_start => @pos, :comp_end => @pos += 3, :found_in => __method__)
714
+ @constructs << DateConstruct.new(date: @curdate.x_weeks_from_day(@length, @curdate.dayindex), comp_start: @pos, comp_end: @pos += 3, found_in: __method__)
629
715
  end
630
716
 
631
717
  def match_x_weeks_from_yesterday
632
- @components[@pos+3] == "yesterday" # "x weeks from yesterday"
718
+ @components[@pos + 3] == 'yesterday' # "x weeks from yesterday"
633
719
  end
634
720
 
635
721
  def found_x_weeks_from_yesterday
636
- @constructs << DateConstruct.new(:date => @curdate.sub_days(1).add_weeks(@length), :comp_start => @pos, :comp_end => @pos += 3, :found_in => __method__)
722
+ @constructs << DateConstruct.new(date: @curdate.sub_days(1).add_weeks(@length), comp_start: @pos, comp_end: @pos += 3, found_in: __method__)
637
723
  end
638
724
 
639
725
  def match_x_months_from
640
- ConstructFinder.digits_only?(@components[@pos]) && @components[@pos+1] =~ /^months?$/ && @components[@pos+2] == "from" && @length = @components[@pos].to_i # if "x months from"
726
+ ConstructFinder.digits_only?(@components[@pos]) && @components[@pos + 1] =~ /^months?$/ && @components[@pos + 2] == 'from' && @length = @components[@pos].to_i # if "x months from"
641
727
  end
642
728
 
643
729
  def match_x_months_from_dayname
644
- @day_index = ZDate.days_of_week.index(@components[@pos+3]) # if "x months from monday"
730
+ @day_index = ZDate.days_of_week.index(@components[@pos + 3]) # if "x months from monday"
645
731
  end
646
732
 
647
733
  def found_x_months_from_dayname
648
- @constructs << DateConstruct.new(:date => @curdate.this(@day_index).add_months(@length), :comp_start => @pos, :comp_end => @pos += 3, :found_in => __method__)
734
+ @constructs << DateConstruct.new(date: @curdate.this(@day_index).add_months(@length), comp_start: @pos, comp_end: @pos += 3, found_in: __method__)
649
735
  end
650
736
 
651
737
  def match_x_months_from_this_dayname
652
- @components[@pos+3] == "this" && @day_index = ZDate.days_of_week.index(@components[@pos+4]) # if "x months from this monday"
738
+ @components[@pos + 3] == 'this' && @day_index = ZDate.days_of_week.index(@components[@pos + 4]) # if "x months from this monday"
653
739
  end
654
740
 
655
741
  def found_x_months_from_this_dayname
656
- @constructs << DateConstruct.new(:date => @curdate.this(@day_index).add_months(@length), :comp_start => @pos, :comp_end => @pos += 4, :found_in => __method__)
742
+ @constructs << DateConstruct.new(date: @curdate.this(@day_index).add_months(@length), comp_start: @pos, comp_end: @pos += 4, found_in: __method__)
657
743
  end
658
744
 
659
745
  def match_x_months_from_next_dayname
660
- @components[@pos+3] == "next" && @day_index = ZDate.days_of_week.index(@components[@pos+4]) # if "x months from next monday"
746
+ @components[@pos + 3] == 'next' && @day_index = ZDate.days_of_week.index(@components[@pos + 4]) # if "x months from next monday"
661
747
  end
662
748
 
663
749
  def found_x_months_from_next_dayname
664
- @constructs << DateConstruct.new(:date => @curdate.next(@day_index).add_months(@length), :comp_start => @pos, :comp_end => @pos += 4, :found_in => __method__)
750
+ @constructs << DateConstruct.new(date: @curdate.next(@day_index).add_months(@length), comp_start: @pos, comp_end: @pos += 4, found_in: __method__)
665
751
  end
666
752
 
667
753
  def match_x_months_from_tomorrow
668
- @components[@pos+3] == "tomorrow" # if "x months from tomorrow"
754
+ @components[@pos + 3] == 'tomorrow' # if "x months from tomorrow"
669
755
  end
670
756
 
671
757
  def found_x_months_from_tomorrow
672
- @constructs << DateConstruct.new(:date => @curdate.add_days(1).add_months(@length), :comp_start => @pos, :comp_end => @pos += 3, :found_in => __method__)
758
+ @constructs << DateConstruct.new(date: @curdate.add_days(1).add_months(@length), comp_start: @pos, comp_end: @pos += 3, found_in: __method__)
673
759
  end
674
760
 
675
761
  def match_x_months_from_now
676
- @components[@pos+3] =~ /\b(today)|(now)\b/ # if "x months from today"
762
+ @components[@pos + 3] =~ /\b(today)|(now)\b/ # if "x months from today"
677
763
  end
678
764
 
679
765
  def found_x_months_from_now
680
- @constructs << DateConstruct.new(:date => @curdate.add_months(@length), :comp_start => @pos, :comp_end => @pos += 3, :found_in => __method__)
766
+ @constructs << DateConstruct.new(date: @curdate.add_months(@length), comp_start: @pos, comp_end: @pos += 3, found_in: __method__)
681
767
  end
682
768
 
683
769
  def match_x_months_from_yesterday
684
- @components[@pos+3] == "yesterday" # "x months from yesterday"
770
+ @components[@pos + 3] == 'yesterday' # "x months from yesterday"
685
771
  end
686
772
 
687
773
  def found_x_months_from_yesterday
688
- @constructs << DateConstruct.new(:date => @curdate.sub_days(1).add_months(@length), :comp_start => @pos, :comp_end => @pos += 3, :found_in => __method__)
774
+ @constructs << DateConstruct.new(date: @curdate.sub_days(1).add_months(@length), comp_start: @pos, comp_end: @pos += 3, found_in: __method__)
689
775
  end
690
776
 
691
777
  def match_x_days_from
692
- ConstructFinder.digits_only?(@components[@pos]) && @components[@pos+1] =~ /^days?$/ && @components[@pos+2] == "from" && @length = @components[@pos].to_i # 3 days from
778
+ ConstructFinder.digits_only?(@components[@pos]) && @components[@pos + 1] =~ /^days?$/ && @components[@pos + 2] == 'from' && @length = @components[@pos].to_i # 3 days from
693
779
  end
694
780
 
695
781
  def match_x_days_from_now
696
- @components[@pos+3] =~ /\b(now)|(today)\b/ # 3 days from today; 3 days from now
782
+ @components[@pos + 3] =~ /\b(now)|(today)\b/ # 3 days from today; 3 days from now
697
783
  end
698
784
 
699
785
  def found_x_days_from_now
700
- @constructs << DateConstruct.new(:date => @curdate.add_days(@length), :comp_start => @pos, :comp_end => @pos += 3, :found_in => __method__)
786
+ @constructs << DateConstruct.new(date: @curdate.add_days(@length), comp_start: @pos, comp_end: @pos += 3, found_in: __method__)
701
787
  end
702
788
 
703
789
  def match_x_days_from_dayname
704
- @day_index = ZDate.days_of_week.index(@components[@pos+3]) # 3 days from monday, why would someone do this?
790
+ @day_index = ZDate.days_of_week.index(@components[@pos + 3]) # 3 days from monday, why would someone do this?
705
791
  end
706
792
 
707
793
  def found_x_days_from_dayname
708
- @constructs << DateConstruct.new(:date => @curdate.this(@day_index).add_days(@length), :comp_start => @pos, :comp_end => @pos += 3, :found_in => __method__)
794
+ @constructs << DateConstruct.new(date: @curdate.this(@day_index).add_days(@length), comp_start: @pos, comp_end: @pos += 3, found_in: __method__)
709
795
  end
710
796
 
711
797
  def match_x_dayname_from
712
- ConstructFinder.digits_only?(@components[@pos]) && (@day_index = ZDate.days_of_week.index(@components[@pos+1])) && @components[@pos+2] == "from" && @length = @components[@pos].to_i # "2 tuesdays from"
798
+ ConstructFinder.digits_only?(@components[@pos]) && (@day_index = ZDate.days_of_week.index(@components[@pos + 1])) && @components[@pos + 2] == 'from' && @length = @components[@pos].to_i # "2 tuesdays from"
713
799
  end
714
800
 
715
801
  def match_x_dayname_from_now
716
- @components[@pos+3] =~ /\b(today)|(now)\b/ # if "2 tuesdays from now"
802
+ @components[@pos + 3] =~ /\b(today)|(now)\b/ # if "2 tuesdays from now"
717
803
  end
718
804
 
719
805
  def found_x_dayname_from_now
720
806
  # this isn't exactly intuitive. If someone says "two tuesday from now" and it is tuesday, they mean "in two weeks." If it is not tuesday, they mean "next tuesday"
721
807
  d = (@days_index == @curdate.dayindex) ? @curdate.add_weeks(@length) : @curdate.x_weeks_from_day(@length - 1, @day_index)
722
- @constructs << DateConstruct.new(:date => d, :comp_start => @pos, :comp_end => @pos += 3, :found_in => __method__)
808
+ @constructs << DateConstruct.new(date: d, comp_start: @pos, comp_end: @pos += 3, found_in: __method__)
723
809
  end
724
810
 
725
811
  def match_x_dayname_from_tomorrow
726
- @components[@pos+3] == "tomorrow"
812
+ @components[@pos + 3] == 'tomorrow'
727
813
  end
728
814
 
729
815
  def found_x_dayname_from_tomorrow
730
816
  # If someone says "two tuesday from tomorrow" and tomorrow is tuesday, they mean "two weeks from tomorrow." If it is not tuesday, this person does not make sense, but we can interpet it as "next tuesday"
731
817
  tomorrow_index = (@curdate.dayindex + 1) % 7
732
818
  d = (@days_index == tomorrow_index) ? @curdate.add_days(1).add_weeks(@length) : @curdate.x_weeks_from_day(@length - 1, @day_index)
733
- @constructs << DateConstruct.new(:date => d, :comp_start => @pos, :comp_end => @pos += 3, :found_in => __method__)
819
+ @constructs << DateConstruct.new(date: d, comp_start: @pos, comp_end: @pos += 3, found_in: __method__)
734
820
  end
735
821
 
736
822
  def match_x_dayname_from_yesterday
737
- @components[@pos+3] == "yesterday"
823
+ @components[@pos + 3] == 'yesterday'
738
824
  end
739
825
 
740
826
  def found_x_dayname_from_yesterday
741
827
  # If someone says "two tuesday from yesterday" and yesterday was tuesday, they mean "two weeks from yesterday." If it is not tuesday, this person does not make sense, but we can interpet it as "next tuesday"
742
828
  yesterday_index = (@curdate.dayindex == 0 ? 6 : @curdate.dayindex - 1)
743
829
  d = (@days_index == yesterday_index) ? @curdate.sub_days(1).add_weeks(@length) : @curdate.x_weeks_from_day(@length - 1, @day_index)
744
- @constructs << DateConstruct.new(:date => d, :comp_start => @pos, :comp_end => @pos += 3, :found_in => __method__)
830
+ @constructs << DateConstruct.new(date: d, comp_start: @pos, comp_end: @pos += 3, found_in: __method__)
745
831
  end
746
832
 
747
833
  def match_x_dayname_from_this
748
- @components[@pos+3] == "this" # "two tuesdays from this"
834
+ @components[@pos + 3] == 'this' # "two tuesdays from this"
749
835
  end
750
836
 
751
837
  def found_x_dayname_from_this
752
- dc = DateConstruct.new(:date => @curdate.this(@day_index).add_weeks(@length), :comp_start => @pos, :found_in => __method__)
753
- if @components[@post+4] == "one" || ZDate.days_of_week.index(@components[@pos+4]) # talk about redundant (2 tuesdays from this one, 2 tuesdays from this tuesday)
838
+ dc = DateConstruct.new(date: @curdate.this(@day_index).add_weeks(@length), comp_start: @pos, found_in: __method__)
839
+ if @components[@post + 4] == 'one' || ZDate.days_of_week.index(@components[@pos + 4]) # talk about redundant (2 tuesdays from this one, 2 tuesdays from this tuesday)
754
840
  dc.comp_end = @pos += 4
755
841
  else
756
842
  dc.comp_end = @pos += 3
@@ -759,12 +845,12 @@ module Nickel
759
845
  end
760
846
 
761
847
  def match_x_dayname_from_next
762
- @components[@pos+3] == "next" # "two tuesdays from next"
848
+ @components[@pos + 3] == 'next' # "two tuesdays from next"
763
849
  end
764
850
 
765
851
  def found_x_dayname_from_next
766
- dc = DateConstruct.new(:date => @curdate.next(@day_index).add_weeks(@length), :comp_start => @pos, :found_in => __method__)
767
- if @components[@post+4] == "one" || ZDate.days_of_week.index(@components[@pos+4]) # talk about redundant (2 tuesdays from next one, 2 tuesdays from next tuesday)
852
+ dc = DateConstruct.new(date: @curdate.next(@day_index).add_weeks(@length), comp_start: @pos, found_in: __method__)
853
+ if @components[@post + 4] == 'one' || ZDate.days_of_week.index(@components[@pos + 4]) # talk about redundant (2 tuesdays from next one, 2 tuesdays from next tuesday)
768
854
  dc.comp_end = @pos += 4
769
855
  else
770
856
  dc.comp_end = @pos += 3
@@ -773,62 +859,61 @@ module Nickel
773
859
  end
774
860
 
775
861
  def match_x_minutes_from_now
776
- ConstructFinder.digits_only?(@components[@pos]) && @components[@pos+1] =~ /minutes?/ && @components[@pos+2] == "from" && @components[@pos+3] =~ /^(today|now)$/ && @length = @components[@pos].to_i
862
+ ConstructFinder.digits_only?(@components[@pos]) && @components[@pos + 1] =~ /minutes?/ && @components[@pos + 2] == 'from' && @components[@pos + 3] =~ /^(today|now)$/ && @length = @components[@pos].to_i
777
863
  end
778
864
 
779
865
  def found_x_minutes_from_now
780
866
  date = nil # define out of scope of block
781
- time = @curtime.add_minutes(@length) {|days_to_increment| date = @curdate.add_days(days_to_increment)}
782
- @constructs << DateConstruct.new(:date => date, :comp_start => @pos, :comp_end => @pos + 4, :found_in => __method__)
783
- @constructs << TimeConstruct.new(:time => time, :comp_start => @pos, :comp_end => @pos += 4, :found_in => __method__)
867
+ time = @curtime.add_minutes(@length) { |days_to_increment| date = @curdate.add_days(days_to_increment) }
868
+ @constructs << DateConstruct.new(date: date, comp_start: @pos, comp_end: @pos + 4, found_in: __method__)
869
+ @constructs << TimeConstruct.new(time: time, comp_start: @pos, comp_end: @pos += 4, found_in: __method__)
784
870
  end
785
871
 
786
872
  def match_x_hours_from_now
787
- ConstructFinder.digits_only?(@components[@pos]) && @components[@pos+1] =~ /hours?/ && @components[@pos+2] == "from" && @components[@pos+3] =~ /^(today|now)$/ && @length = @components[@pos].to_i
873
+ ConstructFinder.digits_only?(@components[@pos]) && @components[@pos + 1] =~ /hours?/ && @components[@pos + 2] == 'from' && @components[@pos + 3] =~ /^(today|now)$/ && @length = @components[@pos].to_i
788
874
  end
789
875
 
790
876
  def found_x_hours_from_now
791
877
  date = nil
792
- time = @curtime.add_hours(@length) {|days_to_increment| date = @curdate.add_days(days_to_increment)}
793
- @constructs << DateConstruct.new(:date => date, :comp_start => @pos, :comp_end => @pos + 4, :found_in => __method__)
794
- @constructs << TimeConstruct.new(:time => time, :comp_start => @pos, :comp_end => @pos += 4, :found_in => __method__)
878
+ time = @curtime.add_hours(@length) { |days_to_increment| date = @curdate.add_days(days_to_increment) }
879
+ @constructs << DateConstruct.new(date: date, comp_start: @pos, comp_end: @pos + 4, found_in: __method__)
880
+ @constructs << TimeConstruct.new(time: time, comp_start: @pos, comp_end: @pos += 4, found_in: __method__)
795
881
  end
796
882
 
797
883
  def match_ordinal_dayname
798
- @components[@pos]=~/(1st|2nd|3rd|4th|5th)/ && (@day_index = ZDate.days_of_week.index(@components[@pos+1])) && @week_num = @components[@pos].to_i # last saturday
884
+ @components[@pos] =~ /(1st|2nd|3rd|4th|5th)/ && (@day_index = ZDate.days_of_week.index(@components[@pos + 1])) && @week_num = @components[@pos].to_i # last saturday
799
885
  end
800
886
 
801
887
  def match_ordinal_dayname_this_month
802
- @components[@pos+2] == "this" && @components[@pos+3] == "month" # last saturday this month
888
+ @components[@pos + 2] == 'this' && @components[@pos + 3] == 'month' # last saturday this month
803
889
  end
804
890
 
805
891
  def found_ordinal_dayname_this_month
806
- @constructs << DateConstruct.new(:date => @curdate.ordinal_dayindex(@week_num, @day_index), :comp_start => @pos, :comp_end => @pos += 3, :found_in => __method__)
892
+ @constructs << DateConstruct.new(date: @curdate.ordinal_dayindex(@week_num, @day_index), comp_start: @pos, comp_end: @pos += 3, found_in: __method__)
807
893
  end
808
894
 
809
895
  def match_ordinal_dayname_next_month
810
- @components[@pos+2] == "next" && @components[@pos+3] == "month" # 1st monday next month
896
+ @components[@pos + 2] == 'next' && @components[@pos + 3] == 'month' # 1st monday next month
811
897
  end
812
898
 
813
899
  def found_ordinal_dayname_next_month
814
- @constructs << DateConstruct.new(:date => @curdate.add_months(1).ordinal_dayindex(@week_num, @day_index), :comp_start => @pos, :comp_end => @pos += 3, :found_in => __method__)
900
+ @constructs << DateConstruct.new(date: @curdate.add_months(1).ordinal_dayindex(@week_num, @day_index), comp_start: @pos, comp_end: @pos += 3, found_in: __method__)
815
901
  end
816
902
 
817
903
  def match_ordinal_dayname_monthname
818
- @month_index = ZDate.months_of_year.index(@components[@pos+2]) # second friday december
904
+ @month_index = ZDate.months_of_year.index(@components[@pos + 2]) # second friday december
819
905
  end
820
906
 
821
907
  def found_ordinal_dayname_monthname
822
- @constructs << DateConstruct.new(:date => @curdate.jump_to_month(@month_index + 1).ordinal_dayindex(@week_num, @day_index), :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
908
+ @constructs << DateConstruct.new(date: @curdate.jump_to_month(@month_index + 1).ordinal_dayindex(@week_num, @day_index), comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
823
909
  end
824
910
 
825
-
826
911
  def match_ordinal_this_month
827
- @components[@pos]=~/(0?[1-9]|[12][0-9]|3[01])(st|nd|rd|th)/ && @components[@pos+1] == 'this' && @components[@pos+2] = 'month' && @length = @components[@pos].to_i # 28th this month
912
+ @components[@pos] =~ /(0?[1-9]|[12][0-9]|3[01])(st|nd|rd|th)/ && @components[@pos + 1] == 'this' && @components[@pos + 2] = 'month' && @length = @components[@pos].to_i # 28th this month
828
913
  end
829
914
 
830
915
  def match_ordinal_next_month
831
- @components[@pos]=~/(0?[1-9]|[12][0-9]|3[01])(st|nd|rd|th)/ && @components[@pos+1] == 'next' && @components[@pos+2] = 'month' && @length = @components[@pos].to_i # 28th next month
916
+ @components[@pos] =~ /(0?[1-9]|[12][0-9]|3[01])(st|nd|rd|th)/ && @components[@pos + 1] == 'next' && @components[@pos + 2] = 'month' && @length = @components[@pos].to_i # 28th next month
832
917
  end
833
918
 
834
919
  def found_ordinal_this_month
@@ -838,178 +923,177 @@ module Nickel
838
923
  else
839
924
  date = @curdate.beginning_of_month.add_days(@length - 1)
840
925
  end
841
- @constructs << DateConstruct.new(:date => date, :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
926
+ @constructs << DateConstruct.new(date: date, comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
842
927
  end
843
928
 
844
929
  def found_ordinal_next_month
845
- @constructs << DateConstruct.new(:date => @curdate.add_months(1).beginning_of_month.add_days(@length - 1), :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
930
+ @constructs << DateConstruct.new(date: @curdate.add_months(1).beginning_of_month.add_days(@length - 1), comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
846
931
  end
847
932
 
848
-
849
933
  def match_first_day
850
- @components[@pos] == "1st" && @components[@pos+1] == "day" # 1st day
934
+ @components[@pos] == '1st' && @components[@pos + 1] == 'day' # 1st day
851
935
  end
852
936
 
853
937
  def match_first_day_this_month
854
- @components[@pos+2] == "this" && @components[@pos+3] == "month" # 1st day this month
938
+ @components[@pos + 2] == 'this' && @components[@pos + 3] == 'month' # 1st day this month
855
939
  end
856
940
 
857
941
  def found_first_day_this_month
858
- @constructs << DateConstruct.new(:date => @curdate.beginning_of_month, :comp_start => @pos, :comp_end => @pos += 3, :found_in => __method__)
942
+ @constructs << DateConstruct.new(date: @curdate.beginning_of_month, comp_start: @pos, comp_end: @pos += 3, found_in: __method__)
859
943
  end
860
944
 
861
945
  def match_first_day_next_month
862
- @components[@pos+2] == "next" && @components[@pos+3] == "month" # 1st day next month
946
+ @components[@pos + 2] == 'next' && @components[@pos + 3] == 'month' # 1st day next month
863
947
  end
864
948
 
865
949
  def found_first_day_next_month
866
- @constructs << DateConstruct.new(:date => @curdate.add_months(1).beginning_of_month, :comp_start => @pos, :comp_end => @pos += 3, :found_in => __method__)
950
+ @constructs << DateConstruct.new(date: @curdate.add_months(1).beginning_of_month, comp_start: @pos, comp_end: @pos += 3, found_in: __method__)
867
951
  end
868
952
 
869
953
  def match_first_day_monthname
870
- @month_index = ZDate.months_of_year.index(@components[@pos+2]) # 1st day december
954
+ @month_index = ZDate.months_of_year.index(@components[@pos + 2]) # 1st day december
871
955
  end
872
956
 
873
957
  def found_first_day_monthname
874
- @constructs << DateConstruct.new(:date => @curdate.jump_to_month(@month_index + 1), :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
958
+ @constructs << DateConstruct.new(date: @curdate.jump_to_month(@month_index + 1), comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
875
959
  end
876
960
 
877
961
  def match_last_day
878
- @components[@pos] == "last" && @components[@pos+1] == "day" # last day
962
+ @components[@pos] == 'last' && @components[@pos + 1] == 'day' # last day
879
963
  end
880
964
 
881
965
  def match_last_day_this_month
882
- @components[@pos+2] == "this" && @components[@pos+3] == "month" # 1st day this month
966
+ @components[@pos + 2] == 'this' && @components[@pos + 3] == 'month' # 1st day this month
883
967
  end
884
968
 
885
969
  def found_last_day_this_month
886
- @constructs << DateConstruct.new(:date => @curdate.end_of_month, :comp_start => @pos, :comp_end => @pos += 3, :found_in => __method__)
970
+ @constructs << DateConstruct.new(date: @curdate.end_of_month, comp_start: @pos, comp_end: @pos += 3, found_in: __method__)
887
971
  end
888
972
 
889
973
  def match_last_day_next_month
890
- @components[@pos+2] == "next" && @components[@pos+3] == "month" # 1st day next month
974
+ @components[@pos + 2] == 'next' && @components[@pos + 3] == 'month' # 1st day next month
891
975
  end
892
976
 
893
977
  def found_last_day_next_month
894
- @constructs << DateConstruct.new(:date => @curdate.add_months(1).end_of_month, :comp_start => @pos, :comp_end => @pos += 3, :found_in => __method__)
978
+ @constructs << DateConstruct.new(date: @curdate.add_months(1).end_of_month, comp_start: @pos, comp_end: @pos += 3, found_in: __method__)
895
979
  end
896
980
 
897
981
  def match_last_day_monthname
898
- @month_index = ZDate.months_of_year.index(@components[@pos+2]) # 1st day december
982
+ @month_index = ZDate.months_of_year.index(@components[@pos + 2]) # 1st day december
899
983
  end
900
984
 
901
985
  def found_last_day_monthname
902
- @constructs << DateConstruct.new(:date => @curdate.jump_to_month(@month_index + 1).end_of_month, :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
986
+ @constructs << DateConstruct.new(date: @curdate.jump_to_month(@month_index + 1).end_of_month, comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
903
987
  end
904
988
 
905
989
  def match_at
906
- @components[@pos]=="at"
990
+ @components[@pos] == 'at'
907
991
  end
908
992
 
909
993
  def match_at_time
910
- @components[@pos+1] && @time1 = ZTime.interpret(@components[@pos+1])
994
+ @components[@pos + 1] && @time1 = ZTime.interpret(@components[@pos + 1])
911
995
  end
912
996
 
913
997
  def match_at_time_through_time
914
- @components[@pos+2] =~ /^(to|until|through)$/ && @components[@pos+3] && @time2 = ZTime.interpret(@components[@pos+3])
998
+ @components[@pos + 2] =~ /^(to|until|through)$/ && @components[@pos + 3] && @time2 = ZTime.interpret(@components[@pos + 3])
915
999
  end
916
1000
 
917
1001
  def found_at_time_through_time
918
- @constructs << TimeSpanConstruct.new(:start_time => @time1, :end_time => @time2, :comp_start => @pos, :comp_end => @pos += 3, :found_in => __method__)
1002
+ @constructs << TimeSpanConstruct.new(start_time: @time1, end_time: @time2, comp_start: @pos, comp_end: @pos += 3, found_in: __method__)
919
1003
  end
920
1004
 
921
1005
  def found_at_time
922
- @constructs << TimeConstruct.new(:time => @time1, :comp_start => @pos, :comp_end => @pos += 1, :found_in => __method__)
1006
+ @constructs << TimeConstruct.new(time: @time1, comp_start: @pos, comp_end: @pos += 1, found_in: __method__)
923
1007
  end
924
1008
 
925
1009
  def match_all_day
926
- @components[@pos]=="all" && @components[@pos+1]=="day" # all day
1010
+ @components[@pos] == 'all' && @components[@pos + 1] == 'day' # all day
927
1011
  end
928
1012
 
929
1013
  def found_all_day
930
- @constructs << TimeConstruct.new(:time => nil, :comp_start => @pos, :comp_end => @pos += 1, :found_in => __method__)
1014
+ @constructs << TimeConstruct.new(time: nil, comp_start: @pos, comp_end: @pos += 1, found_in: __method__)
931
1015
  end
932
1016
 
933
1017
  def match_tomorrow
934
- @components[@pos]=="tomorrow"
1018
+ @components[@pos] == 'tomorrow'
935
1019
  end
936
1020
 
937
1021
  def match_tomorrow_through
938
- @components[@pos+1]=="until" || @components[@pos+1] == "to" || @components[@pos+1] == "through" # "tomorrow through"
1022
+ @components[@pos + 1] == 'until' || @components[@pos + 1] == 'to' || @components[@pos + 1] == 'through' # "tomorrow through"
939
1023
  end
940
1024
 
941
1025
  def match_tomorrow_through_dayname
942
- @day_index = ZDate.days_of_week.index(@components[@pos+2]) # tomorrow through thursday
1026
+ @day_index = ZDate.days_of_week.index(@components[@pos + 2]) # tomorrow through thursday
943
1027
  end
944
1028
 
945
1029
  def found_tomorrow_through_dayname
946
- @constructs << DateSpanConstruct.new(:start_date => @curdate.add_days(1), :end_date => @curdate.add_days(1).this(@day_index), :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
1030
+ @constructs << DateSpanConstruct.new(start_date: @curdate.add_days(1), end_date: @curdate.add_days(1).this(@day_index), comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
947
1031
  end
948
1032
 
949
1033
  def match_tomorrow_through_date
950
- @date1 = ZDate.interpret(@components[@pos+2], @curdate) # tomorrow until 9/21
1034
+ @date1 = ZDate.interpret(@components[@pos + 2], @curdate) # tomorrow until 9/21
951
1035
  end
952
1036
 
953
1037
  def found_tomorrow_through_date
954
- @constructs << DateSpanConstruct.new(:start_date => @curdate.add_days(1), :end_date => @date1, :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
1038
+ @constructs << DateSpanConstruct.new(start_date: @curdate.add_days(1), end_date: @date1, comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
955
1039
  end
956
1040
 
957
1041
  def found_tomorrow
958
- @constructs << DateConstruct.new(:date => @curdate.add_days(1), :comp_start => @pos, :comp_end => @pos, :found_in => __method__)
1042
+ @constructs << DateConstruct.new(date: @curdate.add_days(1), comp_start: @pos, comp_end: @pos, found_in: __method__)
959
1043
  end
960
1044
 
961
1045
  def match_now
962
- @components[@pos]=="today" || @components[@pos]=="now"
1046
+ @components[@pos] == 'today' || @components[@pos] == 'now'
963
1047
  end
964
1048
 
965
1049
  def match_now_through
966
- @components[@pos+1]=="until" || @components[@pos+1] == "to" || @components[@pos+1] == "through" # "today through"
1050
+ @components[@pos + 1] == 'until' || @components[@pos + 1] == 'to' || @components[@pos + 1] == 'through' # "today through"
967
1051
  end
968
1052
 
969
1053
  def match_now_through_dayname
970
- @day_index = ZDate.days_of_week.index(@components[@pos+2]) # today through thursday
1054
+ @day_index = ZDate.days_of_week.index(@components[@pos + 2]) # today through thursday
971
1055
  end
972
1056
 
973
1057
  def found_now_through_dayname
974
- @constructs << DateSpanConstruct.new(:start_date => @curdate, :end_date => @curdate.this(@day_index), :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
1058
+ @constructs << DateSpanConstruct.new(start_date: @curdate, end_date: @curdate.this(@day_index), comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
975
1059
  end
976
1060
 
977
1061
  # redundant!! preprocess this out of here!
978
1062
  def match_now_through_following_dayname
979
- @components[@pos+2] =~ /following|this/ && @day_index = ZDate.days_of_week.index(@components[@pos+3]) # today through following friday
1063
+ @components[@pos + 2] =~ /following|this/ && @day_index = ZDate.days_of_week.index(@components[@pos + 3]) # today through following friday
980
1064
  end
981
1065
 
982
1066
  # redundant!! preprocess this out of here!
983
1067
  def found_now_through_following_dayname
984
- @constructs << DateSpanConstruct.new(:start_date => @curdate, :end_date => @curdate.this(@day_index), :comp_start => @pos, :comp_end => @pos += 3, :found_in => __method__)
1068
+ @constructs << DateSpanConstruct.new(start_date: @curdate, end_date: @curdate.this(@day_index), comp_start: @pos, comp_end: @pos += 3, found_in: __method__)
985
1069
  end
986
1070
 
987
1071
  def match_now_through_date
988
- @date1 = ZDate.interpret(@components[@pos+2], @curdate) # now until 9/21
1072
+ @date1 = ZDate.interpret(@components[@pos + 2], @curdate) # now until 9/21
989
1073
  end
990
1074
 
991
1075
  def found_now_through_date
992
- @constructs << DateSpanConstruct.new(:start_date => @curdate, :end_date => @date1, :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
1076
+ @constructs << DateSpanConstruct.new(start_date: @curdate, end_date: @date1, comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
993
1077
  end
994
1078
 
995
1079
  def match_now_through_tomorrow
996
- @components[@pos+2]=="tomorrow"
1080
+ @components[@pos + 2] == 'tomorrow'
997
1081
  end
998
1082
 
999
1083
  def found_now_through_tomorrow
1000
- @constructs << DateSpanConstruct.new(:start_date => @curdate, :end_date => @curdate.add_days(1), :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
1084
+ @constructs << DateSpanConstruct.new(start_date: @curdate, end_date: @curdate.add_days(1), comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
1001
1085
  end
1002
1086
 
1003
1087
  def match_now_through_next_dayname
1004
- @components[@pos+2] == "next" && @day_index = ZDate.days_of_week.index(@components[@pos+3]) # Today through next friday
1088
+ @components[@pos + 2] == 'next' && @day_index = ZDate.days_of_week.index(@components[@pos + 3]) # Today through next friday
1005
1089
  end
1006
1090
 
1007
1091
  def found_now_through_next_dayname
1008
- @constructs << DateSpanConstruct.new(:start_date => @curdate, :end_date => @curdate.next(@day_index), :comp_start => @pos, :comp_end => @pos += 3, :found_in => __method__)
1092
+ @constructs << DateSpanConstruct.new(start_date: @curdate, end_date: @curdate.next(@day_index), comp_start: @pos, comp_end: @pos += 3, found_in: __method__)
1009
1093
  end
1010
1094
 
1011
1095
  def found_now
1012
- @constructs << DateConstruct.new(:date => @curdate, :comp_start => @pos, :comp_end => @pos, :found_in => __method__)
1096
+ @constructs << DateConstruct.new(date: @curdate, comp_start: @pos, comp_end: @pos, found_in: __method__)
1013
1097
  end
1014
1098
 
1015
1099
  def match_dayname
@@ -1017,23 +1101,23 @@ module Nickel
1017
1101
  end
1018
1102
 
1019
1103
  def match_dayname_the_ordinal
1020
- @components[@pos+1] == "the" && @date1 = ZDate.interpret(@components[@pos+2], @curdate) # if "tue the 23rd"
1104
+ @components[@pos + 1] == 'the' && @date1 = ZDate.interpret(@components[@pos + 2], @curdate) # if "tue the 23rd"
1021
1105
  end
1022
1106
 
1023
1107
  def found_dayname_the_ordinal
1024
1108
  # user may have specified "monday the 2nd" while in the previous month, so first check if dayname matches date.dayname, if it doesn't increment by a month and check again
1025
1109
  if @date1.dayname == @components[@pos] || ((tmp = @date1.add_months(1)) && tmp.dayname == @components[@pos] && @date1 = tmp)
1026
- @constructs << DateConstruct.new(:date => @date1, :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
1110
+ @constructs << DateConstruct.new(date: @date1, comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
1027
1111
  end
1028
1112
  end
1029
1113
 
1030
1114
  def match_dayname_x_weeks_from_this
1031
- @components[@pos+1] && ConstructFinder.digits_only?(@components[@pos+1]) && @components[@pos+2] =~ /\bweeks?\b/ && @components[@pos+3] =~ /\b(from)|(after)/ && @components[@pos+4] == "this" && @length = @components[@pos+1] # "monday two weeks from this
1115
+ @components[@pos + 1] && ConstructFinder.digits_only?(@components[@pos + 1]) && @components[@pos + 2] =~ /\bweeks?\b/ && @components[@pos + 3] =~ /\b(from)|(after)/ && @components[@pos + 4] == 'this' && @length = @components[@pos + 1] # "monday two weeks from this
1032
1116
  end
1033
1117
 
1034
1118
  def found_dayname_x_weeks_from_this
1035
- dc = DateConstruct.new(:date => @curdate.this(@dayindex).add_weeks(@length), :comp_start => @pos, :found_in => __method__)
1036
- if ZDate.days_of_week.include?(@components[@pos+5]) #redundant
1119
+ dc = DateConstruct.new(date: @curdate.this(@dayindex).add_weeks(@length), comp_start: @pos, found_in: __method__)
1120
+ if ZDate.days_of_week.include?(@components[@pos + 5]) # redundant
1037
1121
  dc.comp_end = @pos += 5
1038
1122
  else
1039
1123
  dc.comp_end = @pos += 4
@@ -1042,12 +1126,12 @@ module Nickel
1042
1126
  end
1043
1127
 
1044
1128
  def match_dayname_x_weeks_from_next
1045
- @components[@pos+1] && ConstructFinder.digits_only?(@components[@pos+1]) && @components[@pos+2] =~ /\bweeks?\b/ && @components[@pos+3] =~ /\b(from)|(after)/ && @components[@pos+4] == "next" && @length = @components[@pos+1] # "monday two weeks from this
1129
+ @components[@pos + 1] && ConstructFinder.digits_only?(@components[@pos + 1]) && @components[@pos + 2] =~ /\bweeks?\b/ && @components[@pos + 3] =~ /\b(from)|(after)/ && @components[@pos + 4] == 'next' && @length = @components[@pos + 1] # "monday two weeks from this
1046
1130
  end
1047
1131
 
1048
1132
  def found_dayname_x_weeks_from_next
1049
- dc = DateConstruct.new(:date => @curdate.next(@dayindex).add_weeks(@length), :comp_start => @pos, :found_in => __method__)
1050
- if ZDate.days_of_week.include?(@components[@pos+5]) #redundant
1133
+ dc = DateConstruct.new(date: @curdate.next(@dayindex).add_weeks(@length), comp_start: @pos, found_in: __method__)
1134
+ if ZDate.days_of_week.include?(@components[@pos + 5]) # redundant
1051
1135
  dc.comp_end = @pos += 5
1052
1136
  else
1053
1137
  dc.comp_end = @pos += 4
@@ -1058,21 +1142,21 @@ module Nickel
1058
1142
  # redundant, same as found_this_dayname
1059
1143
  def found_dayname
1060
1144
  day_to_add = @curdate.this(@day_index)
1061
- @constructs << DateConstruct.new(:date => day_to_add, :comp_start => @pos, :comp_end => @pos, :found_in => __method__)
1062
- while @components[@pos+1] && @day_index = ZDate.days_of_week.index(@components[@pos+1])
1145
+ @constructs << DateConstruct.new(date: day_to_add, comp_start: @pos, comp_end: @pos, found_in: __method__)
1146
+ while @components[@pos + 1] && @day_index = ZDate.days_of_week.index(@components[@pos + 1])
1063
1147
  # note @pos gets incremented here:
1064
- @constructs << DateConstruct.new(:date => day_to_add = day_to_add.this(@day_index), :comp_start => @pos + 1, :comp_end => @pos += 1, :found_in => __method__)
1148
+ @constructs << DateConstruct.new(date: day_to_add = day_to_add.this(@day_index), comp_start: @pos + 1, comp_end: @pos += 1, found_in: __method__)
1065
1149
  end
1066
1150
  end
1067
1151
 
1068
1152
  def match_through_monthname
1069
- @components[@pos] == "through" && @month_index = ZDate.months_of_year.index(@components[@pos+1])
1153
+ @components[@pos] == 'through' && @month_index = ZDate.months_of_year.index(@components[@pos + 1])
1070
1154
  end
1071
1155
 
1072
1156
  def found_through_monthname
1073
1157
  # this is really a wrapper, we don't know when the start date is, so make sure @constructs gets wrapper first, as date constructs always have to appear after wrapper
1074
- @constructs << WrapperConstruct.new(:wrapper_type => 1, :comp_start => @pos, :comp_end => @pos + 1, :found_in => __method__)
1075
- @constructs << DateConstruct.new(:date => @curdate.jump_to_month(@month_index + 1).sub_days(1), :comp_start => @pos, :comp_end => @pos += 1, :found_in => __method__)
1158
+ @constructs << WrapperConstruct.new(wrapper_type: 1, comp_start: @pos, comp_end: @pos + 1, found_in: __method__)
1159
+ @constructs << DateConstruct.new(date: @curdate.jump_to_month(@month_index + 1).sub_days(1), comp_start: @pos, comp_end: @pos += 1, found_in: __method__)
1076
1160
  end
1077
1161
 
1078
1162
  def match_monthname
@@ -1083,26 +1167,25 @@ module Nickel
1083
1167
  def found_monthname
1084
1168
  sd = @curdate.jump_to_month(@month_index + 1)
1085
1169
  ed = sd.end_of_month
1086
- @constructs << DateSpanConstruct.new(:start_date => sd, :end_date => ed, :comp_start => @pos, :comp_end => @pos, :found_in => __method__)
1170
+ @constructs << DateSpanConstruct.new(start_date: sd, end_date: ed, comp_start: @pos, comp_end: @pos, found_in: __method__)
1087
1171
  end
1088
1172
 
1089
-
1090
1173
  def match_start
1091
- @components[@pos] == "start"
1174
+ @components[@pos] == 'start'
1092
1175
  end
1093
1176
 
1094
1177
  def found_start
1095
- #wrapper_type 0 is a start wrapper
1096
- @constructs << WrapperConstruct.new(:wrapper_type => 0, :comp_start => @pos, :comp_end => @pos, :found_in => __method__)
1178
+ # wrapper_type 0 is a start wrapper
1179
+ @constructs << WrapperConstruct.new(wrapper_type: 0, comp_start: @pos, comp_end: @pos, found_in: __method__)
1097
1180
  end
1098
1181
 
1099
1182
  def match_through
1100
- @components[@pos] == "through"
1183
+ @components[@pos] == 'through'
1101
1184
  end
1102
1185
 
1103
1186
  def found_through
1104
- #wrapper_type 1 is an end wrapper
1105
- @constructs << WrapperConstruct.new(:wrapper_type => 1, :comp_start => @pos, :comp_end => @pos, :found_in => __method__)
1187
+ # wrapper_type 1 is an end wrapper
1188
+ @constructs << WrapperConstruct.new(wrapper_type: 1, comp_start: @pos, comp_end: @pos, found_in: __method__)
1106
1189
  end
1107
1190
 
1108
1191
  def match_time
@@ -1110,15 +1193,15 @@ module Nickel
1110
1193
  end
1111
1194
 
1112
1195
  def match_time_through_time
1113
- @components[@pos+1] =~ /^(to|through)$/ && @time2 = ZTime.interpret(@components[@pos+2])
1196
+ @components[@pos + 1] =~ /^(to|through)$/ && @time2 = ZTime.interpret(@components[@pos + 2])
1114
1197
  end
1115
1198
 
1116
1199
  def found_time_through_time
1117
- @constructs << TimeSpanConstruct.new(:start_time => @time1, :end_time => @time2, :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
1200
+ @constructs << TimeSpanConstruct.new(start_time: @time1, end_time: @time2, comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
1118
1201
  end
1119
1202
 
1120
1203
  def found_time
1121
- @constructs << TimeConstruct.new(:time => @time1, :comp_start => @pos, :comp_end => @pos, :found_in => __method__)
1204
+ @constructs << TimeConstruct.new(time: @time1, comp_start: @pos, comp_end: @pos, found_in: __method__)
1122
1205
  end
1123
1206
 
1124
1207
  def match_date
@@ -1126,20 +1209,20 @@ module Nickel
1126
1209
  end
1127
1210
 
1128
1211
  def match_date_through_date
1129
- @components[@pos+1] =~ /^(through|to|until)$/ && @date2 = ZDate.interpret(@components[@pos+2], @curdate)
1212
+ @components[@pos + 1] =~ /^(through|to|until)$/ && @date2 = ZDate.interpret(@components[@pos + 2], @curdate)
1130
1213
  end
1131
1214
 
1132
1215
  def found_date_through_date
1133
- @constructs << DateSpanConstruct.new(:start_date => @date1, :end_date => @date2, :comp_start => @pos, :comp_end => @pos += 2, :found_in => __method__)
1216
+ @constructs << DateSpanConstruct.new(start_date: @date1, end_date: @date2, comp_start: @pos, comp_end: @pos += 2, found_in: __method__)
1134
1217
  end
1135
1218
 
1136
1219
  def found_date
1137
- @constructs << DateConstruct.new(:date => @date1, :comp_start => @pos, :comp_end => @pos, :found_in => __method__)
1220
+ @constructs << DateConstruct.new(date: @date1, comp_start: @pos, comp_end: @pos, found_in: __method__)
1138
1221
  end
1139
1222
 
1140
1223
  class << self
1141
1224
  def digits_only?(str)
1142
- str =~ /^\d+$/ #no characters other than digits
1225
+ str =~ /^\d+$/ # no characters other than digits
1143
1226
  end
1144
1227
 
1145
1228
  # valid hour, 24hour, and minute could use some cleaning
@@ -1149,4 +1232,3 @@ module Nickel
1149
1232
  end
1150
1233
  end # END class ConstructFinder
1151
1234
  end
1152
-