Class: Nickel::ConstructFinder
- Inherits:
-
Object
- Object
- Nickel::ConstructFinder
- Defined in:
- lib/nickel/construct_finder.rb
Instance Attribute Summary collapse
-
#components ⇒ Object
readonly
Returns the value of attribute components.
-
#constructs ⇒ Object
readonly
Returns the value of attribute constructs.
Class Method Summary collapse
- .digits_only?(str) ⇒ Boolean
-
.ordinal_only?(str) ⇒ Boolean
valid hour, 24hour, and minute could use some cleaning.
Instance Method Summary collapse
- #big_if_on_current_word ⇒ Object
- #found_all_day ⇒ Object
- #found_at_time ⇒ Object
- #found_at_time_through_time ⇒ Object
- #found_date ⇒ Object
- #found_date_through_date ⇒ Object
-
#found_dayname ⇒ Object
redundant, same as found_this_dayname.
- #found_dayname_the_ordinal ⇒ Object
- #found_dayname_x_weeks_from_next ⇒ Object
- #found_dayname_x_weeks_from_this ⇒ Object
- #found_every_3rd_day ⇒ Object
- #found_every_3rd_dayname ⇒ Object
- #found_every_day ⇒ Object
- #found_every_dayname ⇒ Object
- #found_every_other_day ⇒ Object
- #found_every_other_dayname ⇒ Object
- #found_first_day_monthname ⇒ Object
- #found_first_day_next_month ⇒ Object
- #found_first_day_this_month ⇒ Object
- #found_for_x_days ⇒ Object
- #found_for_x_months ⇒ Object
- #found_for_x_weeks ⇒ Object
- #found_last_day_monthname ⇒ Object
- #found_last_day_next_month ⇒ Object
- #found_last_day_this_month ⇒ Object
- #found_monthname ⇒ Object
- #found_next_dayname ⇒ Object
- #found_next_month ⇒ Object
- #found_next_week ⇒ Object
- #found_next_weekend ⇒ Object
- #found_next_x_days ⇒ Object
- #found_next_x_months ⇒ Object
- #found_next_x_weeks ⇒ Object
- #found_next_x_years ⇒ Object
- #found_now ⇒ Object
- #found_now_through_date ⇒ Object
- #found_now_through_dayname ⇒ Object
-
#found_now_through_following_dayname ⇒ Object
redundant!! preprocess this out of here!.
- #found_now_through_next_dayname ⇒ Object
- #found_now_through_tomorrow ⇒ Object
- #found_ordinal_dayname_monthname ⇒ Object
- #found_ordinal_dayname_next_month ⇒ Object
- #found_ordinal_dayname_this_month ⇒ Object
- #found_ordinal_next_month ⇒ Object
- #found_ordinal_this_month ⇒ Object
- #found_repeats_altdaily ⇒ Object
- #found_repeats_altmonthly_datemonthly ⇒ Object
- #found_repeats_altmonthly_daymonthly ⇒ Object
- #found_repeats_altweekly_vague ⇒ Object
- #found_repeats_daily ⇒ Object
- #found_repeats_datemonthly ⇒ Object
- #found_repeats_daymonthly ⇒ Object
- #found_repeats_threemonthly_datemonthly ⇒ Object
- #found_repeats_threemonthly_daymonthly ⇒ Object
- #found_repeats_weekly_vague ⇒ Object
- #found_start ⇒ Object
- #found_this_dayname ⇒ Object
- #found_this_month ⇒ Object
- #found_this_week ⇒ Object
- #found_through ⇒ Object
- #found_through_monthname ⇒ Object
- #found_time ⇒ Object
- #found_time_through_time ⇒ Object
- #found_tomorrow ⇒ Object
- #found_tomorrow_through_date ⇒ Object
- #found_tomorrow_through_dayname ⇒ Object
- #found_week_of_date ⇒ Object
- #found_week_through_date ⇒ Object
- #found_x_dayname_from_next ⇒ Object
- #found_x_dayname_from_now ⇒ Object
- #found_x_dayname_from_this ⇒ Object
- #found_x_dayname_from_tomorrow ⇒ Object
- #found_x_dayname_from_yesterday ⇒ Object
- #found_x_days_from_dayname ⇒ Object
- #found_x_days_from_now ⇒ Object
- #found_x_hours_from_now ⇒ Object
- #found_x_minutes_from_now ⇒ Object
- #found_x_months_from_dayname ⇒ Object
- #found_x_months_from_next_dayname ⇒ Object
- #found_x_months_from_now ⇒ Object
- #found_x_months_from_this_dayname ⇒ Object
- #found_x_months_from_tomorrow ⇒ Object
- #found_x_months_from_yesterday ⇒ Object
- #found_x_weeks_from_dayname ⇒ Object
- #found_x_weeks_from_next_dayname ⇒ Object
- #found_x_weeks_from_now ⇒ Object
-
#found_x_weeks_from_this_dayname ⇒ Object
Reduntant, preprocess out!.
- #found_x_weeks_from_tomorrow ⇒ Object
- #found_x_weeks_from_yesterday ⇒ Object
-
#initialize(query, curdate, curtime) ⇒ ConstructFinder
constructor
A new instance of ConstructFinder.
- #match_all_day ⇒ Object
- #match_at ⇒ Object
- #match_at_time ⇒ Object
- #match_at_time_through_time ⇒ Object
- #match_date ⇒ Object
- #match_date_through_date ⇒ Object
- #match_dayname ⇒ Object
- #match_dayname_the_ordinal ⇒ Object
- #match_dayname_x_weeks_from_next ⇒ Object
- #match_dayname_x_weeks_from_this ⇒ Object
-
#match_every ⇒ Object
end def big_if_on_current_word.
- #match_every_3rd ⇒ Object
- #match_every_3rd_day ⇒ Object
- #match_every_3rd_dayname ⇒ Object
- #match_every_day ⇒ Object
- #match_every_dayname ⇒ Object
- #match_every_other ⇒ Object
- #match_every_other_day ⇒ Object
- #match_every_other_dayname ⇒ Object
- #match_first_day ⇒ Object
- #match_first_day_monthname ⇒ Object
- #match_first_day_next_month ⇒ Object
- #match_first_day_this_month ⇒ Object
- #match_for_x ⇒ Object
- #match_for_x_days ⇒ Object
- #match_for_x_months ⇒ Object
- #match_for_x_weeks ⇒ Object
- #match_last_day ⇒ Object
- #match_last_day_monthname ⇒ Object
- #match_last_day_next_month ⇒ Object
- #match_last_day_this_month ⇒ Object
- #match_monthname ⇒ Object
- #match_next ⇒ Object
- #match_next_dayname ⇒ Object
- #match_next_month ⇒ Object
- #match_next_week ⇒ Object
- #match_next_weekend ⇒ Object
- #match_next_x ⇒ Object
- #match_next_x_days ⇒ Object
- #match_next_x_months ⇒ Object
- #match_next_x_weeks ⇒ Object
- #match_next_x_years ⇒ Object
- #match_now ⇒ Object
- #match_now_through ⇒ Object
- #match_now_through_date ⇒ Object
- #match_now_through_dayname ⇒ Object
-
#match_now_through_following_dayname ⇒ Object
redundant!! preprocess this out of here!.
- #match_now_through_next_dayname ⇒ Object
- #match_now_through_tomorrow ⇒ Object
- #match_ordinal_dayname ⇒ Object
- #match_ordinal_dayname_monthname ⇒ Object
- #match_ordinal_dayname_next_month ⇒ Object
- #match_ordinal_dayname_this_month ⇒ Object
- #match_ordinal_next_month ⇒ Object
- #match_ordinal_this_month ⇒ Object
- #match_repeats ⇒ Object
- #match_repeats_altdaily ⇒ Object
- #match_repeats_altmonthly ⇒ Object
- #match_repeats_altmonthly_datemonthly ⇒ Object
- #match_repeats_altmonthly_daymonthly ⇒ Object
- #match_repeats_altweekly_vague ⇒ Object
- #match_repeats_daily ⇒ Object
- #match_repeats_datemonthly ⇒ Object
- #match_repeats_daymonthly ⇒ Object
- #match_repeats_monthly ⇒ Object
- #match_repeats_threemonthly ⇒ Object
- #match_repeats_threemonthly_datemonthly ⇒ Object
- #match_repeats_threemonthly_daymonthly ⇒ Object
- #match_repeats_weekly_vague ⇒ Object
- #match_start ⇒ Object
- #match_this ⇒ Object
- #match_this_dayname ⇒ Object
- #match_this_month ⇒ Object
- #match_this_week ⇒ Object
- #match_through ⇒ Object
- #match_through_monthname ⇒ Object
- #match_time ⇒ Object
- #match_time_through_time ⇒ Object
- #match_tomorrow ⇒ Object
- #match_tomorrow_through ⇒ Object
- #match_tomorrow_through_date ⇒ Object
- #match_tomorrow_through_dayname ⇒ Object
- #match_week ⇒ Object
- #match_week_of_date ⇒ Object
- #match_week_through_date ⇒ Object
- #match_x_dayname_from ⇒ Object
- #match_x_dayname_from_next ⇒ Object
- #match_x_dayname_from_now ⇒ Object
- #match_x_dayname_from_this ⇒ Object
- #match_x_dayname_from_tomorrow ⇒ Object
- #match_x_dayname_from_yesterday ⇒ Object
- #match_x_days_from ⇒ Object
- #match_x_days_from_dayname ⇒ Object
- #match_x_days_from_now ⇒ Object
- #match_x_hours_from_now ⇒ Object
- #match_x_minutes_from_now ⇒ Object
- #match_x_months_from ⇒ Object
- #match_x_months_from_dayname ⇒ Object
- #match_x_months_from_next_dayname ⇒ Object
- #match_x_months_from_now ⇒ Object
- #match_x_months_from_this_dayname ⇒ Object
- #match_x_months_from_tomorrow ⇒ Object
- #match_x_months_from_yesterday ⇒ Object
- #match_x_weeks_from ⇒ Object
- #match_x_weeks_from_dayname ⇒ Object
- #match_x_weeks_from_next_dayname ⇒ Object
- #match_x_weeks_from_now ⇒ Object
-
#match_x_weeks_from_this_dayname ⇒ Object
Reduntant, preprocess out!.
- #match_x_weeks_from_tomorrow ⇒ Object
- #match_x_weeks_from_yesterday ⇒ Object
- #reset_instance_vars ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(query, curdate, curtime) ⇒ ConstructFinder
Returns a new instance of ConstructFinder.
9 10 11 12 13 14 15 |
# File 'lib/nickel/construct_finder.rb', line 9 def initialize(query, curdate, curtime) @curdate = curdate @curtime = curtime @components = query.split @pos = 0 # iterator @constructs = [] end |
Instance Attribute Details
#components ⇒ Object (readonly)
Returns the value of attribute components.
7 8 9 |
# File 'lib/nickel/construct_finder.rb', line 7 def components @components end |
#constructs ⇒ Object (readonly)
Returns the value of attribute constructs.
7 8 9 |
# File 'lib/nickel/construct_finder.rb', line 7 def constructs @constructs end |
Class Method Details
.digits_only?(str) ⇒ Boolean
1224 1225 1226 |
# File 'lib/nickel/construct_finder.rb', line 1224 def digits_only?(str) str =~ /^\d+$/ # no characters other than digits end |
.ordinal_only?(str) ⇒ Boolean
valid hour, 24hour, and minute could use some cleaning
1229 1230 1231 |
# File 'lib/nickel/construct_finder.rb', line 1229 def ordinal_only?(str) str =~ %r{^(0?[1-9]|[12][0-9]|3[01])(?:st|nd|rd|th)?$} end |
Instance Method Details
#big_if_on_current_word ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/nickel/construct_finder.rb', line 36 def big_if_on_current_word reset_instance_vars if match_every if match_every_dayname found_every_dayname # every tue elsif match_every_day found_every_day # every day elsif match_every_other if match_every_other_dayname found_every_other_dayname # every other fri elsif match_every_other_day found_every_other_day # every other day end elsif match_every_3rd if match_every_3rd_dayname found_every_3rd_dayname # every third fri elsif match_every_3rd_day found_every_3rd_day # every third day end end elsif match_repeats if match_repeats_daily found_repeats_daily # repeats daily elsif match_repeats_altdaily found_repeats_altdaily # repeats altdaily elsif match_repeats_weekly_vague found_repeats_weekly_vague # repeats weekly elsif match_repeats_altweekly_vague found_repeats_altweekly_vague # repeats altweekly elsif match_repeats_monthly if match_repeats_daymonthly found_repeats_daymonthly # repeats monthly 1st fri elsif match_repeats_datemonthly found_repeats_datemonthly # repeats monthly 22nd end elsif match_repeats_altmonthly if match_repeats_altmonthly_daymonthly found_repeats_altmonthly_daymonthly # repeats altmonthly 1st fri elsif match_repeats_altmonthly_datemonthly found_repeats_altmonthly_datemonthly # repeats altmonthly 22nd end elsif match_repeats_threemonthly if match_repeats_threemonthly_daymonthly found_repeats_threemonthly_daymonthly # repeats threemonthly 1st fri elsif match_repeats_threemonthly_datemonthly found_repeats_threemonthly_datemonthly # repeats threemonthly 22nd end end elsif match_for_x if match_for_x_days found_for_x_days # for 10 days elsif match_for_x_weeks found_for_x_weeks # for 10 weeks elsif match_for_x_months found_for_x_months # for 10 months end elsif match_this if match_this_dayname found_this_dayname # this fri elsif match_this_week found_this_week # this week elsif match_this_month found_this_month # this month (implies 9/1 to 9/30) end # SHOULDN'T "this" HAVE "this weekend" ??? elsif match_next if match_next_weekend found_next_weekend # next weekend --- never hit? elsif match_next_dayname found_next_dayname # next tuesday elsif match_next_x if match_next_x_days found_next_x_days # next 5 days --- shouldn't this be a wrapper? elsif match_next_x_weeks found_next_x_weeks # next 5 weeks --- shouldn't this be a wrapper? elsif match_next_x_months found_next_x_months # next 5 months --- shouldn't this be a wrapper? elsif match_next_x_years found_next_x_years # next 5 years --- shouldn't this be a wrapper? end elsif match_next_week found_next_week elsif match_next_month found_next_month # next month (implies 10/1 to 10/31) end elsif match_week if match_week_of_date found_week_of_date # week of 1/2 elsif match_week_through_date found_week_through_date # week through 1/2 (as in, week ending 1/2) end elsif match_x_weeks_from if match_x_weeks_from_dayname found_x_weeks_from_dayname # 5 weeks from tuesday elsif match_x_weeks_from_this_dayname found_x_weeks_from_this_dayname # 5 weeks from this tuesday elsif match_x_weeks_from_next_dayname found_x_weeks_from_next_dayname # 5 weeks from next tuesday elsif match_x_weeks_from_tomorrow found_x_weeks_from_tomorrow # 5 weeks from tomorrow elsif match_x_weeks_from_now found_x_weeks_from_now # 5 weeks from now elsif match_x_weeks_from_yesterday found_x_weeks_from_yesterday # 5 weeks from yesterday end elsif match_x_months_from if match_x_months_from_dayname found_x_months_from_dayname # 2 months from wed elsif match_x_months_from_this_dayname found_x_months_from_this_dayname # 2 months from this wed elsif match_x_months_from_next_dayname found_x_months_from_next_dayname # 2 months from next wed elsif match_x_months_from_tomorrow found_x_months_from_tomorrow # 2 months from tomorrow elsif match_x_months_from_now found_x_months_from_now # 2 months from now elsif match_x_months_from_yesterday found_x_months_from_yesterday # 2 months from yesterday end elsif match_x_days_from if match_x_days_from_now found_x_days_from_now # 5 days from now elsif match_x_days_from_dayname found_x_days_from_dayname # 5 days from monday end elsif match_x_dayname_from if match_x_dayname_from_now found_x_dayname_from_now # 2 fridays from now elsif match_x_dayname_from_tomorrow found_x_dayname_from_tomorrow # 2 fridays from tomorrow elsif match_x_dayname_from_yesterday found_x_dayname_from_yesterday # 2 fridays from yesterday elsif match_x_dayname_from_this found_x_dayname_from_this # 2 fridays from this one elsif match_x_dayname_from_next found_x_dayname_from_next # 2 fridays from next friday end elsif match_x_minutes_from_now found_x_minutes_from_now # 5 minutes from now elsif match_x_hours_from_now found_x_hours_from_now # 5 hours from now elsif match_ordinal_dayname if match_ordinal_dayname_this_month found_ordinal_dayname_this_month # 2nd friday this month elsif match_ordinal_dayname_next_month found_ordinal_dayname_next_month # 2nd friday next month elsif match_ordinal_dayname_monthname found_ordinal_dayname_monthname # 2nd friday december end elsif match_ordinal_this_month found_ordinal_this_month # 28th this month elsif match_ordinal_next_month found_ordinal_next_month # 28th next month elsif match_first_day if match_first_day_this_month found_first_day_this_month # first day this month elsif match_first_day_next_month found_first_day_next_month # first day next month elsif match_first_day_monthname 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?) end elsif match_last_day if match_last_day_this_month found_last_day_this_month # last day this month elsif match_last_day_next_month found_last_day_next_month # last day next month elsif match_last_day_monthname found_last_day_monthname # last day november end elsif match_at if match_at_time if match_at_time_through_time found_at_time_through_time # at 2 through 5pm else found_at_time # at 2 end end elsif match_all_day found_all_day # all day elsif match_tomorrow if match_tomorrow_through if match_tomorrow_through_dayname found_tomorrow_through_dayname # tomorrow through friday elsif match_tomorrow_through_date found_tomorrow_through_date # tomorrow through august 20th end else found_tomorrow # tomorrow end elsif match_now if match_now_through if match_now_through_dayname found_now_through_dayname # today through friday elsif match_now_through_following_dayname found_now_through_following_dayname # REDUNDANT, PREPROCESS THIS OUT elsif match_now_through_date found_now_through_date # today through 10/1 elsif match_now_through_tomorrow found_now_through_tomorrow # today through tomorrow elsif match_now_through_next_dayname found_now_through_next_dayname # today through next friday end else found_now # today end elsif match_dayname if match_dayname_the_ordinal found_dayname_the_ordinal # monday the 21st elsif match_dayname_x_weeks_from_next found_dayname_x_weeks_from_next # monday 2 weeks from next elsif match_dayname_x_weeks_from_this found_dayname_x_weeks_from_this # monday 2 weeks from this else found_dayname # monday (also monday tuesday wed...) end elsif match_through_monthname found_through_monthname # through december (implies through 11/30) elsif match_monthname found_monthname # december (implies 12/1 to 12/31) # 5th constructor elsif match_start found_start elsif match_through found_through elsif match_time # match time second to last if match_time_through_time found_time_through_time # 10 to 4 else found_time # 10 end elsif match_date # match date last if match_date_through_date found_date_through_date # 5th through the 16th else found_date # 5th end end end |
#found_all_day ⇒ Object
1013 1014 1015 |
# File 'lib/nickel/construct_finder.rb', line 1013 def found_all_day @constructs << NullConstruct.new(comp_start: @pos, comp_end: @pos += 1, found_in: __method__) end |
#found_at_time ⇒ Object
1005 1006 1007 |
# File 'lib/nickel/construct_finder.rb', line 1005 def found_at_time @constructs << TimeConstruct.new(time: @time1, comp_start: @pos, comp_end: @pos += 1, found_in: __method__) end |
#found_at_time_through_time ⇒ Object
1001 1002 1003 |
# File 'lib/nickel/construct_finder.rb', line 1001 def found_at_time_through_time @constructs << TimeSpanConstruct.new(start_time: @time1, end_time: @time2, comp_start: @pos, comp_end: @pos += 3, found_in: __method__) end |
#found_date ⇒ Object
1219 1220 1221 |
# File 'lib/nickel/construct_finder.rb', line 1219 def found_date @constructs << DateConstruct.new(date: @date1, comp_start: @pos, comp_end: @pos, found_in: __method__) end |
#found_date_through_date ⇒ Object
1215 1216 1217 |
# File 'lib/nickel/construct_finder.rb', line 1215 def found_date_through_date @constructs << DateSpanConstruct.new(start_date: @date1, end_date: @date2, comp_start: @pos, comp_end: @pos += 2, found_in: __method__) end |
#found_dayname ⇒ Object
redundant, same as found_this_dayname
1143 1144 1145 1146 1147 1148 1149 1150 |
# File 'lib/nickel/construct_finder.rb', line 1143 def found_dayname day_to_add = @curdate.this(@day_index) @constructs << DateConstruct.new(date: day_to_add, comp_start: @pos, comp_end: @pos, found_in: __method__) while @components[@pos + 1] && @day_index = ZDate.days_of_week.index(@components[@pos + 1]) # note @pos gets incremented here: @constructs << DateConstruct.new(date: day_to_add = day_to_add.this(@day_index), comp_start: @pos + 1, comp_end: @pos += 1, found_in: __method__) end end |
#found_dayname_the_ordinal ⇒ Object
1107 1108 1109 1110 1111 1112 |
# File 'lib/nickel/construct_finder.rb', line 1107 def found_dayname_the_ordinal # 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 if @date1.dayname == @components[@pos] || ((tmp = @date1.add_months(1)) && tmp.dayname == @components[@pos] && @date1 = tmp) @constructs << DateConstruct.new(date: @date1, comp_start: @pos, comp_end: @pos += 2, found_in: __method__) end end |
#found_dayname_x_weeks_from_next ⇒ Object
1132 1133 1134 1135 1136 1137 1138 1139 1140 |
# File 'lib/nickel/construct_finder.rb', line 1132 def found_dayname_x_weeks_from_next dc = DateConstruct.new(date: @curdate.next(@dayindex).add_weeks(@length), comp_start: @pos, found_in: __method__) if ZDate.days_of_week.include?(@components[@pos + 5]) # redundant dc.comp_end = @pos += 5 else dc.comp_end = @pos += 4 end @constructs << h end |
#found_dayname_x_weeks_from_this ⇒ Object
1118 1119 1120 1121 1122 1123 1124 1125 1126 |
# File 'lib/nickel/construct_finder.rb', line 1118 def found_dayname_x_weeks_from_this dc = DateConstruct.new(date: @curdate.this(@dayindex).add_weeks(@length), comp_start: @pos, found_in: __method__) if ZDate.days_of_week.include?(@components[@pos + 5]) # redundant dc.comp_end = @pos += 5 else dc.comp_end = @pos += 4 end @constructs << dc end |
#found_every_3rd_day ⇒ Object
372 373 374 |
# File 'lib/nickel/construct_finder.rb', line 372 def found_every_3rd_day @constructs << RecurrenceConstruct.new(repeats: :threedaily, comp_start: @pos, comp_end: @pos += 2, found_in: __method__) end |
#found_every_3rd_dayname ⇒ Object
358 359 360 361 362 363 364 365 366 |
# File 'lib/nickel/construct_finder.rb', line 358 def found_every_3rd_dayname day_array = [@day_index] j = 3 while @components[@pos + j] && ZDate.days_of_week.index(@components[@pos + j]) # if "every 3rd tue wed thu day_array << ZDate.days_of_week.index(@components[@pos + j]) j += 1 end @constructs << RecurrenceConstruct.new(repeats: :threeweekly, repeats_on: day_array, comp_start: @pos, comp_end: @pos += (j - 1), found_in: __method__) end |
#found_every_day ⇒ Object
320 321 322 |
# File 'lib/nickel/construct_finder.rb', line 320 def found_every_day @constructs << RecurrenceConstruct.new(repeats: :daily, comp_start: @pos, comp_end: @pos += 1, found_in: __method__) end |
#found_every_dayname ⇒ Object
306 307 308 309 310 311 312 313 314 |
# File 'lib/nickel/construct_finder.rb', line 306 def found_every_dayname day_array = [@day_index] j = 2 while @components[@pos + j] && ZDate.days_of_week.index(@components[@pos + j]) # if "every mon tue wed" day_array << ZDate.days_of_week.index(@components[@pos + j]) j += 1 end @constructs << RecurrenceConstruct.new(repeats: :weekly, repeats_on: day_array, comp_start: @pos, comp_end: @pos += (j - 1), found_in: __method__) end |
#found_every_other_day ⇒ Object
346 347 348 |
# File 'lib/nickel/construct_finder.rb', line 346 def found_every_other_day @constructs << RecurrenceConstruct.new(repeats: :altdaily, comp_start: @pos, comp_end: @pos += 2, found_in: __method__) end |
#found_every_other_dayname ⇒ Object
332 333 334 335 336 337 338 339 340 |
# File 'lib/nickel/construct_finder.rb', line 332 def found_every_other_dayname day_array = [@day_index] j = 3 while @components[@pos + j] && ZDate.days_of_week.index(@components[@pos + j]) # if "every other mon tue wed day_array << ZDate.days_of_week.index(@components[@pos + j]) j += 1 end @constructs << RecurrenceConstruct.new(repeats: :altweekly, repeats_on: day_array, comp_start: @pos, comp_end: @pos += (j - 1), found_in: __method__) end |
#found_first_day_monthname ⇒ Object
957 958 959 |
# File 'lib/nickel/construct_finder.rb', line 957 def found_first_day_monthname @constructs << DateConstruct.new(date: @curdate.jump_to_month(@month_index + 1), comp_start: @pos, comp_end: @pos += 2, found_in: __method__) end |
#found_first_day_next_month ⇒ Object
949 950 951 |
# File 'lib/nickel/construct_finder.rb', line 949 def found_first_day_next_month @constructs << DateConstruct.new(date: @curdate.add_months(1).beginning_of_month, comp_start: @pos, comp_end: @pos += 3, found_in: __method__) end |
#found_first_day_this_month ⇒ Object
941 942 943 |
# File 'lib/nickel/construct_finder.rb', line 941 def found_first_day_this_month @constructs << DateConstruct.new(date: @curdate.beginning_of_month, comp_start: @pos, comp_end: @pos += 3, found_in: __method__) end |
#found_for_x_days ⇒ Object
513 514 515 |
# File 'lib/nickel/construct_finder.rb', line 513 def found_for_x_days @constructs << WrapperConstruct.new(wrapper_type: 2, wrapper_length: @length, comp_start: @pos, comp_end: @pos += 2, found_in: __method__) end |
#found_for_x_months ⇒ Object
529 530 531 |
# File 'lib/nickel/construct_finder.rb', line 529 def found_for_x_months @constructs << WrapperConstruct.new(wrapper_type: 4, wrapper_length: @length, comp_start: @pos, comp_end: @pos += 2, found_in: __method__) end |
#found_for_x_weeks ⇒ Object
521 522 523 |
# File 'lib/nickel/construct_finder.rb', line 521 def found_for_x_weeks @constructs << WrapperConstruct.new(wrapper_type: 3, wrapper_length: @length, comp_start: @pos, comp_end: @pos += 2, found_in: __method__) end |
#found_last_day_monthname ⇒ Object
985 986 987 |
# File 'lib/nickel/construct_finder.rb', line 985 def found_last_day_monthname @constructs << DateConstruct.new(date: @curdate.jump_to_month(@month_index + 1).end_of_month, comp_start: @pos, comp_end: @pos += 2, found_in: __method__) end |
#found_last_day_next_month ⇒ Object
977 978 979 |
# File 'lib/nickel/construct_finder.rb', line 977 def found_last_day_next_month @constructs << DateConstruct.new(date: @curdate.add_months(1).end_of_month, comp_start: @pos, comp_end: @pos += 3, found_in: __method__) end |
#found_last_day_this_month ⇒ Object
969 970 971 |
# File 'lib/nickel/construct_finder.rb', line 969 def found_last_day_this_month @constructs << DateConstruct.new(date: @curdate.end_of_month, comp_start: @pos, comp_end: @pos += 3, found_in: __method__) end |
#found_monthname ⇒ Object
1167 1168 1169 1170 1171 |
# File 'lib/nickel/construct_finder.rb', line 1167 def found_monthname sd = @curdate.jump_to_month(@month_index + 1) ed = sd.end_of_month @constructs << DateSpanConstruct.new(start_date: sd, end_date: ed, comp_start: @pos, comp_end: @pos, found_in: __method__) end |
#found_next_dayname ⇒ Object
584 585 586 587 588 589 590 591 |
# File 'lib/nickel/construct_finder.rb', line 584 def found_next_dayname day_to_add = @curdate.next(@day_index) @constructs << DateConstruct.new(date: day_to_add, comp_start: @pos, comp_end: @pos += 1, found_in: __method__) while @components[@pos + 1] && @day_index = ZDate.days_of_week.index(@components[@pos + 1]) # note @pos gets incremented on each pass @constructs << DateConstruct.new(date: day_to_add = day_to_add.this(@day_index), comp_start: @pos + 1, comp_end: @pos += 1, found_in: __method__) end end |
#found_next_month ⇒ Object
644 645 646 647 648 |
# File 'lib/nickel/construct_finder.rb', line 644 def found_next_month sd = @curdate.add_months(1).beginning_of_month ed = sd.end_of_month @constructs << DateSpanConstruct.new(start_date: sd, end_date: ed, comp_start: @pos, comp_end: @pos += 1, found_in: __method__) end |
#found_next_week ⇒ Object
633 634 635 636 637 |
# File 'lib/nickel/construct_finder.rb', line 633 def found_next_week sd = @curdate.add_days(7) ed = sd.add_days(7) @constructs << DateSpanConstruct.new(start_date: sd, end_date: ed, comp_start: @pos, comp_end: @pos += 1, found_in: __method__) end |
#found_next_weekend ⇒ Object
574 575 576 577 578 |
# File 'lib/nickel/construct_finder.rb', line 574 def found_next_weekend dsc = DateSpanConstruct.new(start_date: @curdate.next(5), comp_start: @pos, comp_end: @pos += 1, found_in: __method__) dsc.end_date = dsc.start_date.add_days(1) @constructs << dsc end |
#found_next_x_days ⇒ Object
601 602 603 |
# File 'lib/nickel/construct_finder.rb', line 601 def found_next_x_days @constructs << DateSpanConstruct.new(start_date: @curdate, end_date: @curdate.add_days(@length), comp_start: @pos, comp_end: @pos += 2, found_in: __method__) end |
#found_next_x_months ⇒ Object
617 618 619 |
# File 'lib/nickel/construct_finder.rb', line 617 def found_next_x_months @constructs << DateSpanConstruct.new(start_date: @curdate, end_date: @curdate.add_months(@length), comp_start: @pos, comp_end: @pos += 2, found_in: __method__) end |
#found_next_x_weeks ⇒ Object
609 610 611 |
# File 'lib/nickel/construct_finder.rb', line 609 def found_next_x_weeks @constructs << DateSpanConstruct.new(start_date: @curdate, end_date: @curdate.add_weeks(@length), comp_start: @pos, comp_end: @pos += 2, found_in: __method__) end |
#found_next_x_years ⇒ Object
625 626 627 |
# File 'lib/nickel/construct_finder.rb', line 625 def found_next_x_years @constructs << DateSpanConstruct.new(start_date: @curdate, end_date: @curdate.add_years(@length), comp_start: @pos, comp_end: @pos += 2, found_in: __method__) end |
#found_now ⇒ Object
1095 1096 1097 |
# File 'lib/nickel/construct_finder.rb', line 1095 def found_now @constructs << DateConstruct.new(date: @curdate, comp_start: @pos, comp_end: @pos, found_in: __method__) end |
#found_now_through_date ⇒ Object
1075 1076 1077 |
# File 'lib/nickel/construct_finder.rb', line 1075 def found_now_through_date @constructs << DateSpanConstruct.new(start_date: @curdate, end_date: @date1, comp_start: @pos, comp_end: @pos += 2, found_in: __method__) end |
#found_now_through_dayname ⇒ Object
1057 1058 1059 |
# File 'lib/nickel/construct_finder.rb', line 1057 def found_now_through_dayname @constructs << DateSpanConstruct.new(start_date: @curdate, end_date: @curdate.this(@day_index), comp_start: @pos, comp_end: @pos += 2, found_in: __method__) end |
#found_now_through_following_dayname ⇒ Object
redundant!! preprocess this out of here!
1067 1068 1069 |
# File 'lib/nickel/construct_finder.rb', line 1067 def found_now_through_following_dayname @constructs << DateSpanConstruct.new(start_date: @curdate, end_date: @curdate.this(@day_index), comp_start: @pos, comp_end: @pos += 3, found_in: __method__) end |
#found_now_through_next_dayname ⇒ Object
1091 1092 1093 |
# File 'lib/nickel/construct_finder.rb', line 1091 def found_now_through_next_dayname @constructs << DateSpanConstruct.new(start_date: @curdate, end_date: @curdate.next(@day_index), comp_start: @pos, comp_end: @pos += 3, found_in: __method__) end |
#found_now_through_tomorrow ⇒ Object
1083 1084 1085 |
# File 'lib/nickel/construct_finder.rb', line 1083 def found_now_through_tomorrow @constructs << DateSpanConstruct.new(start_date: @curdate, end_date: @curdate.add_days(1), comp_start: @pos, comp_end: @pos += 2, found_in: __method__) end |
#found_ordinal_dayname_monthname ⇒ Object
907 908 909 |
# File 'lib/nickel/construct_finder.rb', line 907 def found_ordinal_dayname_monthname @constructs << DateConstruct.new(date: @curdate.jump_to_month(@month_index + 1).(@week_num, @day_index), comp_start: @pos, comp_end: @pos += 2, found_in: __method__) end |
#found_ordinal_dayname_next_month ⇒ Object
899 900 901 |
# File 'lib/nickel/construct_finder.rb', line 899 def found_ordinal_dayname_next_month @constructs << DateConstruct.new(date: @curdate.add_months(1).(@week_num, @day_index), comp_start: @pos, comp_end: @pos += 3, found_in: __method__) end |
#found_ordinal_dayname_this_month ⇒ Object
891 892 893 |
# File 'lib/nickel/construct_finder.rb', line 891 def found_ordinal_dayname_this_month @constructs << DateConstruct.new(date: @curdate.(@week_num, @day_index), comp_start: @pos, comp_end: @pos += 3, found_in: __method__) end |
#found_ordinal_next_month ⇒ Object
929 930 931 |
# File 'lib/nickel/construct_finder.rb', line 929 def found_ordinal_next_month @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__) end |
#found_ordinal_this_month ⇒ Object
919 920 921 922 923 924 925 926 927 |
# File 'lib/nickel/construct_finder.rb', line 919 def found_ordinal_this_month if @curdate.day > @length # e.g. it is the 30th of the month and a user types "1st of the month", they mean "first of next month" date = @curdate.add_months(1).beginning_of_month.add_days(@length - 1) else date = @curdate.beginning_of_month.add_days(@length - 1) end @constructs << DateConstruct.new(date: date, comp_start: @pos, comp_end: @pos += 2, found_in: __method__) end |
#found_repeats_altdaily ⇒ Object
392 393 394 |
# File 'lib/nickel/construct_finder.rb', line 392 def found_repeats_altdaily @constructs << RecurrenceConstruct.new(repeats: :altdaily, comp_start: @pos, comp_end: @pos += 1, found_in: __method__) end |
#found_repeats_altmonthly_datemonthly ⇒ Object
465 466 467 468 469 470 471 472 |
# File 'lib/nickel/construct_finder.rb', line 465 def found_repeats_altmonthly_datemonthly j = 3 while @components[@pos + j] && ConstructFinder.ordinal_only?(@components[@pos + j]) @date_array << @components[@pos + j].to_i j += 1 end @constructs << RecurrenceConstruct.new(repeats: :altdatemonthly, repeats_on: @date_array, comp_start: @pos, comp_end: @pos += (j - 1), found_in: __method__) end |
#found_repeats_altmonthly_daymonthly ⇒ Object
451 452 453 454 455 456 457 458 459 |
# File 'lib/nickel/construct_finder.rb', line 451 def found_repeats_altmonthly_daymonthly rep_array = [[@week_num, @day_index]] j = 4 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])) rep_array << [@week_num, @day_index] j += 2 end @constructs << RecurrenceConstruct.new(repeats: :altdaymonthly, repeats_on: rep_array, comp_start: @pos, comp_end: @pos += (j - 1), found_in: __method__) end |
#found_repeats_altweekly_vague ⇒ Object
408 409 410 |
# File 'lib/nickel/construct_finder.rb', line 408 def found_repeats_altweekly_vague @constructs << RecurrenceConstruct.new(repeats: :altweekly, comp_start: @pos, comp_end: @pos += 1, found_in: __method__) end |
#found_repeats_daily ⇒ Object
384 385 386 |
# File 'lib/nickel/construct_finder.rb', line 384 def found_repeats_daily @constructs << RecurrenceConstruct.new(repeats: :daily, comp_start: @pos, comp_end: @pos += 1, found_in: __method__) end |
#found_repeats_datemonthly ⇒ Object
434 435 436 437 438 439 440 441 |
# File 'lib/nickel/construct_finder.rb', line 434 def found_repeats_datemonthly j = 3 while @components[@pos + j] && ConstructFinder.ordinal_only?(@components[@pos + j]) @date_array << @components[@pos + j].to_i j += 1 end @constructs << RecurrenceConstruct.new(repeats: :datemonthly, repeats_on: @date_array, comp_start: @pos, comp_end: @pos += (j - 1), found_in: __method__) end |
#found_repeats_daymonthly ⇒ Object
420 421 422 423 424 425 426 427 428 |
# File 'lib/nickel/construct_finder.rb', line 420 def found_repeats_daymonthly rep_array = [[@week_num, @day_index]] # That is NOT a typo, not sure what I meant by that! maybe the nested array j = 4 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])) rep_array << [@week_num, @day_index] j += 2 end @constructs << RecurrenceConstruct.new(repeats: :daymonthly, repeats_on: rep_array, comp_start: @pos, comp_end: @pos += (j - 1), found_in: __method__) end |
#found_repeats_threemonthly_datemonthly ⇒ Object
496 497 498 499 500 501 502 503 |
# File 'lib/nickel/construct_finder.rb', line 496 def found_repeats_threemonthly_datemonthly j = 3 while @components[@pos + j] && ConstructFinder.ordinal_only?(@components[@pos + j]) @date_array << @components[@pos + j].to_i j += 1 end @constructs << RecurrenceConstruct.new(repeats: :threedatemonthly, repeats_on: @date_array, comp_start: @pos, comp_end: @pos += (j - 1), found_in: __method__) end |
#found_repeats_threemonthly_daymonthly ⇒ Object
482 483 484 485 486 487 488 489 490 |
# File 'lib/nickel/construct_finder.rb', line 482 def found_repeats_threemonthly_daymonthly rep_array = [[@week_num, @day_index]] # That is NOT a typo j = 4 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])) rep_array << [@week_num, @day_index] j += 2 end @constructs << RecurrenceConstruct.new(repeats: :threedaymonthly, repeats_on: rep_array, comp_start: @pos, comp_end: @pos += (j - 1), found_in: __method__) end |
#found_repeats_weekly_vague ⇒ Object
400 401 402 |
# File 'lib/nickel/construct_finder.rb', line 400 def found_repeats_weekly_vague @constructs << RecurrenceConstruct.new(repeats: :weekly, comp_start: @pos, comp_end: @pos += 1, found_in: __method__) end |
#found_start ⇒ Object
1177 1178 1179 1180 |
# File 'lib/nickel/construct_finder.rb', line 1177 def found_start # wrapper_type 0 is a start wrapper @constructs << WrapperConstruct.new(wrapper_type: 0, comp_start: @pos, comp_end: @pos, found_in: __method__) end |
#found_this_dayname ⇒ Object
541 542 543 544 545 546 547 548 |
# File 'lib/nickel/construct_finder.rb', line 541 def found_this_dayname day_to_add = @curdate.this(@day_index) @constructs << DateConstruct.new(date: day_to_add, comp_start: @pos, comp_end: @pos += 1, found_in: __method__) while @components[@pos + 1] && @day_index = ZDate.days_of_week.index(@components[@pos + 1]) # note @pos gets incremented on each pass @constructs << DateConstruct.new(date: day_to_add = day_to_add.this(@day_index), comp_start: @pos + 1, comp_end: @pos += 1, found_in: __method__) end end |
#found_this_month ⇒ Object
562 563 564 |
# File 'lib/nickel/construct_finder.rb', line 562 def found_this_month @constructs << DateSpanConstruct.new(start_date: @curdate, end_date: @curdate.end_of_month, comp_start: @pos, comp_end: @pos += 1, found_in: __method__) end |
#found_this_week ⇒ Object
554 555 556 |
# File 'lib/nickel/construct_finder.rb', line 554 def found_this_week @constructs << DateSpanConstruct.new(start_date: @curdate, end_date: @curdate.add_days(7), comp_start: @pos, comp_end: @pos += 1, found_in: __method__) end |
#found_through ⇒ Object
1186 1187 1188 1189 |
# File 'lib/nickel/construct_finder.rb', line 1186 def found_through # wrapper_type 1 is an end wrapper @constructs << WrapperConstruct.new(wrapper_type: 1, comp_start: @pos, comp_end: @pos, found_in: __method__) end |
#found_through_monthname ⇒ Object
1156 1157 1158 1159 1160 |
# File 'lib/nickel/construct_finder.rb', line 1156 def found_through_monthname # 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 @constructs << WrapperConstruct.new(wrapper_type: 1, comp_start: @pos, comp_end: @pos + 1, found_in: __method__) @constructs << DateConstruct.new(date: @curdate.jump_to_month(@month_index + 1).sub_days(1), comp_start: @pos, comp_end: @pos += 1, found_in: __method__) end |
#found_time ⇒ Object
1203 1204 1205 |
# File 'lib/nickel/construct_finder.rb', line 1203 def found_time @constructs << TimeConstruct.new(time: @time1, comp_start: @pos, comp_end: @pos, found_in: __method__) end |
#found_time_through_time ⇒ Object
1199 1200 1201 |
# File 'lib/nickel/construct_finder.rb', line 1199 def found_time_through_time @constructs << TimeSpanConstruct.new(start_time: @time1, end_time: @time2, comp_start: @pos, comp_end: @pos += 2, found_in: __method__) end |
#found_tomorrow ⇒ Object
1041 1042 1043 |
# File 'lib/nickel/construct_finder.rb', line 1041 def found_tomorrow @constructs << DateConstruct.new(date: @curdate.add_days(1), comp_start: @pos, comp_end: @pos, found_in: __method__) end |
#found_tomorrow_through_date ⇒ Object
1037 1038 1039 |
# File 'lib/nickel/construct_finder.rb', line 1037 def found_tomorrow_through_date @constructs << DateSpanConstruct.new(start_date: @curdate.add_days(1), end_date: @date1, comp_start: @pos, comp_end: @pos += 2, found_in: __method__) end |
#found_tomorrow_through_dayname ⇒ Object
1029 1030 1031 |
# File 'lib/nickel/construct_finder.rb', line 1029 def found_tomorrow_through_dayname @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__) end |
#found_week_of_date ⇒ Object
658 659 660 |
# File 'lib/nickel/construct_finder.rb', line 658 def found_week_of_date @constructs << DateSpanConstruct.new(start_date: @date1, end_date: @date1.add_days(7), comp_start: @pos, comp_end: @pos += 2, found_in: __method__) end |
#found_week_through_date ⇒ Object
666 667 668 |
# File 'lib/nickel/construct_finder.rb', line 666 def found_week_through_date @constructs << DateSpanConstruct.new(start_date: @date1.sub_days(7), end_date: @date1, comp_start: @pos, comp_end: @pos += 2, found_in: __method__) end |
#found_x_dayname_from_next ⇒ Object
851 852 853 854 855 856 857 858 859 |
# File 'lib/nickel/construct_finder.rb', line 851 def found_x_dayname_from_next dc = DateConstruct.new(date: @curdate.next(@day_index).add_weeks(@length), comp_start: @pos, found_in: __method__) 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) dc.comp_end = @pos += 4 else dc.comp_end = @pos += 3 end @constructs << dc end |
#found_x_dayname_from_now ⇒ Object
805 806 807 808 809 |
# File 'lib/nickel/construct_finder.rb', line 805 def found_x_dayname_from_now # 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" d = (@days_index == @curdate.) ? @curdate.add_weeks(@length) : @curdate.x_weeks_from_day(@length - 1, @day_index) @constructs << DateConstruct.new(date: d, comp_start: @pos, comp_end: @pos += 3, found_in: __method__) end |
#found_x_dayname_from_this ⇒ Object
837 838 839 840 841 842 843 844 845 |
# File 'lib/nickel/construct_finder.rb', line 837 def found_x_dayname_from_this dc = DateConstruct.new(date: @curdate.this(@day_index).add_weeks(@length), comp_start: @pos, found_in: __method__) 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) dc.comp_end = @pos += 4 else dc.comp_end = @pos += 3 end @constructs << dc end |
#found_x_dayname_from_tomorrow ⇒ Object
815 816 817 818 819 820 |
# File 'lib/nickel/construct_finder.rb', line 815 def found_x_dayname_from_tomorrow # 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" tomorrow_index = (@curdate. + 1) % 7 d = (@days_index == tomorrow_index) ? @curdate.add_days(1).add_weeks(@length) : @curdate.x_weeks_from_day(@length - 1, @day_index) @constructs << DateConstruct.new(date: d, comp_start: @pos, comp_end: @pos += 3, found_in: __method__) end |
#found_x_dayname_from_yesterday ⇒ Object
826 827 828 829 830 831 |
# File 'lib/nickel/construct_finder.rb', line 826 def found_x_dayname_from_yesterday # 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" yesterday_index = (@curdate. == 0 ? 6 : @curdate. - 1) d = (@days_index == yesterday_index) ? @curdate.sub_days(1).add_weeks(@length) : @curdate.x_weeks_from_day(@length - 1, @day_index) @constructs << DateConstruct.new(date: d, comp_start: @pos, comp_end: @pos += 3, found_in: __method__) end |
#found_x_days_from_dayname ⇒ Object
793 794 795 |
# File 'lib/nickel/construct_finder.rb', line 793 def found_x_days_from_dayname @constructs << DateConstruct.new(date: @curdate.this(@day_index).add_days(@length), comp_start: @pos, comp_end: @pos += 3, found_in: __method__) end |
#found_x_days_from_now ⇒ Object
785 786 787 |
# File 'lib/nickel/construct_finder.rb', line 785 def found_x_days_from_now @constructs << DateConstruct.new(date: @curdate.add_days(@length), comp_start: @pos, comp_end: @pos += 3, found_in: __method__) end |
#found_x_hours_from_now ⇒ Object
876 877 878 879 880 881 |
# File 'lib/nickel/construct_finder.rb', line 876 def found_x_hours_from_now date = nil time = @curtime.add_hours(@length) { |days_to_increment| date = @curdate.add_days(days_to_increment) } @constructs << DateConstruct.new(date: date, comp_start: @pos, comp_end: @pos + 4, found_in: __method__) @constructs << TimeConstruct.new(time: time, comp_start: @pos, comp_end: @pos += 4, found_in: __method__) end |
#found_x_minutes_from_now ⇒ Object
865 866 867 868 869 870 |
# File 'lib/nickel/construct_finder.rb', line 865 def found_x_minutes_from_now date = nil # define out of scope of block time = @curtime.add_minutes(@length) { |days_to_increment| date = @curdate.add_days(days_to_increment) } @constructs << DateConstruct.new(date: date, comp_start: @pos, comp_end: @pos + 4, found_in: __method__) @constructs << TimeConstruct.new(time: time, comp_start: @pos, comp_end: @pos += 4, found_in: __method__) end |
#found_x_months_from_dayname ⇒ Object
733 734 735 |
# File 'lib/nickel/construct_finder.rb', line 733 def found_x_months_from_dayname @constructs << DateConstruct.new(date: @curdate.this(@day_index).add_months(@length), comp_start: @pos, comp_end: @pos += 3, found_in: __method__) end |
#found_x_months_from_next_dayname ⇒ Object
749 750 751 |
# File 'lib/nickel/construct_finder.rb', line 749 def found_x_months_from_next_dayname @constructs << DateConstruct.new(date: @curdate.next(@day_index).add_months(@length), comp_start: @pos, comp_end: @pos += 4, found_in: __method__) end |
#found_x_months_from_now ⇒ Object
765 766 767 |
# File 'lib/nickel/construct_finder.rb', line 765 def found_x_months_from_now @constructs << DateConstruct.new(date: @curdate.add_months(@length), comp_start: @pos, comp_end: @pos += 3, found_in: __method__) end |
#found_x_months_from_this_dayname ⇒ Object
741 742 743 |
# File 'lib/nickel/construct_finder.rb', line 741 def found_x_months_from_this_dayname @constructs << DateConstruct.new(date: @curdate.this(@day_index).add_months(@length), comp_start: @pos, comp_end: @pos += 4, found_in: __method__) end |
#found_x_months_from_tomorrow ⇒ Object
757 758 759 |
# File 'lib/nickel/construct_finder.rb', line 757 def found_x_months_from_tomorrow @constructs << DateConstruct.new(date: @curdate.add_days(1).add_months(@length), comp_start: @pos, comp_end: @pos += 3, found_in: __method__) end |
#found_x_months_from_yesterday ⇒ Object
773 774 775 |
# File 'lib/nickel/construct_finder.rb', line 773 def found_x_months_from_yesterday @constructs << DateConstruct.new(date: @curdate.sub_days(1).add_months(@length), comp_start: @pos, comp_end: @pos += 3, found_in: __method__) end |
#found_x_weeks_from_dayname ⇒ Object
678 679 680 |
# File 'lib/nickel/construct_finder.rb', line 678 def found_x_weeks_from_dayname @constructs << DateConstruct.new(date: @curdate.x_weeks_from_day(@length, @day_index), comp_start: @pos, comp_end: @pos += 3, found_in: __method__) end |
#found_x_weeks_from_next_dayname ⇒ Object
697 698 699 |
# File 'lib/nickel/construct_finder.rb', line 697 def found_x_weeks_from_next_dayname @constructs << DateConstruct.new(date: @curdate.x_weeks_from_day(@length + 1, @day_index), comp_start: @pos, comp_end: @pos += 4, found_in: __method__) end |
#found_x_weeks_from_now ⇒ Object
713 714 715 |
# File 'lib/nickel/construct_finder.rb', line 713 def found_x_weeks_from_now @constructs << DateConstruct.new(date: @curdate.x_weeks_from_day(@length, @curdate.), comp_start: @pos, comp_end: @pos += 3, found_in: __method__) end |
#found_x_weeks_from_this_dayname ⇒ Object
Reduntant, preprocess out!
688 689 690 691 |
# File 'lib/nickel/construct_finder.rb', line 688 def found_x_weeks_from_this_dayname # 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 @constructs << DateConstruct.new(date: @curdate.x_weeks_from_day(@length, @day_index), comp_start: @pos, comp_end: @pos += 4, found_in: __method__) end |
#found_x_weeks_from_tomorrow ⇒ Object
705 706 707 |
# File 'lib/nickel/construct_finder.rb', line 705 def found_x_weeks_from_tomorrow @constructs << DateConstruct.new(date: @curdate.add_days(1).add_weeks(@length), comp_start: @pos, comp_end: @pos += 3, found_in: __method__) end |
#found_x_weeks_from_yesterday ⇒ Object
721 722 723 |
# File 'lib/nickel/construct_finder.rb', line 721 def found_x_weeks_from_yesterday @constructs << DateConstruct.new(date: @curdate.sub_days(1).add_weeks(@length), comp_start: @pos, comp_end: @pos += 3, found_in: __method__) end |
#match_all_day ⇒ Object
1009 1010 1011 |
# File 'lib/nickel/construct_finder.rb', line 1009 def match_all_day @components[@pos] == 'all' && @components[@pos + 1] == 'day' # all day end |
#match_at ⇒ Object
989 990 991 |
# File 'lib/nickel/construct_finder.rb', line 989 def match_at @components[@pos] == 'at' end |
#match_at_time ⇒ Object
993 994 995 |
# File 'lib/nickel/construct_finder.rb', line 993 def match_at_time @components[@pos + 1] && @time1 = ZTime.interpret(@components[@pos + 1]) end |
#match_at_time_through_time ⇒ Object
997 998 999 |
# File 'lib/nickel/construct_finder.rb', line 997 def match_at_time_through_time @components[@pos + 2] =~ /^(to|until|through)$/ && @components[@pos + 3] && @time2 = ZTime.interpret(@components[@pos + 3]) end |
#match_date ⇒ Object
1207 1208 1209 |
# File 'lib/nickel/construct_finder.rb', line 1207 def match_date @date1 = ZDate.interpret(@components[@pos], @curdate) end |
#match_date_through_date ⇒ Object
1211 1212 1213 |
# File 'lib/nickel/construct_finder.rb', line 1211 def match_date_through_date @components[@pos + 1] =~ /^(through|to|until)$/ && @date2 = ZDate.interpret(@components[@pos + 2], @curdate) end |
#match_dayname ⇒ Object
1099 1100 1101 |
# File 'lib/nickel/construct_finder.rb', line 1099 def match_dayname @day_index = ZDate.days_of_week.index(@components[@pos]) end |
#match_dayname_the_ordinal ⇒ Object
1103 1104 1105 |
# File 'lib/nickel/construct_finder.rb', line 1103 def match_dayname_the_ordinal @components[@pos + 1] == 'the' && @date1 = ZDate.interpret(@components[@pos + 2], @curdate) # if "tue the 23rd" end |
#match_dayname_x_weeks_from_next ⇒ Object
1128 1129 1130 |
# File 'lib/nickel/construct_finder.rb', line 1128 def match_dayname_x_weeks_from_next @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 end |
#match_dayname_x_weeks_from_this ⇒ Object
1114 1115 1116 |
# File 'lib/nickel/construct_finder.rb', line 1114 def match_dayname_x_weeks_from_this @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 end |
#match_every ⇒ Object
end def big_if_on_current_word
298 299 300 |
# File 'lib/nickel/construct_finder.rb', line 298 def match_every @components[@pos] == 'every' end |
#match_every_3rd ⇒ Object
350 351 352 |
# File 'lib/nickel/construct_finder.rb', line 350 def match_every_3rd @components[@pos + 1] == '3rd' end |
#match_every_3rd_day ⇒ Object
368 369 370 |
# File 'lib/nickel/construct_finder.rb', line 368 def match_every_3rd_day @components[@pos + 2] == 'day' # if "every 3rd day" end |
#match_every_3rd_dayname ⇒ Object
354 355 356 |
# File 'lib/nickel/construct_finder.rb', line 354 def match_every_3rd_dayname @day_index = ZDate.days_of_week.index(@components[@pos + 2]) # if "every 3rd tue" end |
#match_every_day ⇒ Object
316 317 318 |
# File 'lib/nickel/construct_finder.rb', line 316 def match_every_day @components[@pos + 1] == 'day' end |
#match_every_dayname ⇒ Object
302 303 304 |
# File 'lib/nickel/construct_finder.rb', line 302 def match_every_dayname @day_index = ZDate.days_of_week.index(@components[@pos + 1]) # if "every [day]" end |
#match_every_other ⇒ Object
324 325 326 |
# File 'lib/nickel/construct_finder.rb', line 324 def match_every_other @components[@pos + 1] =~ /other|2nd/ end |
#match_every_other_day ⇒ Object
342 343 344 |
# File 'lib/nickel/construct_finder.rb', line 342 def match_every_other_day @components[@pos + 2] == 'day' # if "every other day" end |
#match_every_other_dayname ⇒ Object
328 329 330 |
# File 'lib/nickel/construct_finder.rb', line 328 def match_every_other_dayname @day_index = ZDate.days_of_week.index(@components[@pos + 2]) # if "every other mon" end |
#match_first_day ⇒ Object
933 934 935 |
# File 'lib/nickel/construct_finder.rb', line 933 def match_first_day @components[@pos] == '1st' && @components[@pos + 1] == 'day' # 1st day end |
#match_first_day_monthname ⇒ Object
953 954 955 |
# File 'lib/nickel/construct_finder.rb', line 953 def match_first_day_monthname @month_index = ZDate.months_of_year.index(@components[@pos + 2]) # 1st day december end |
#match_first_day_next_month ⇒ Object
945 946 947 |
# File 'lib/nickel/construct_finder.rb', line 945 def match_first_day_next_month @components[@pos + 2] == 'next' && @components[@pos + 3] == 'month' # 1st day next month end |
#match_first_day_this_month ⇒ Object
937 938 939 |
# File 'lib/nickel/construct_finder.rb', line 937 def match_first_day_this_month @components[@pos + 2] == 'this' && @components[@pos + 3] == 'month' # 1st day this month end |
#match_for_x ⇒ Object
505 506 507 |
# File 'lib/nickel/construct_finder.rb', line 505 def match_for_x @components[@pos] == 'for' && ConstructFinder.digits_only?(@components[@pos + 1]) && @length = @components[@pos + 1].to_i end |
#match_for_x_days ⇒ Object
509 510 511 |
# File 'lib/nickel/construct_finder.rb', line 509 def match_for_x_days @components[@pos + 2] =~ /days?/ end |
#match_for_x_months ⇒ Object
525 526 527 |
# File 'lib/nickel/construct_finder.rb', line 525 def match_for_x_months @components[@pos + 2] =~ /months?/ end |
#match_for_x_weeks ⇒ Object
517 518 519 |
# File 'lib/nickel/construct_finder.rb', line 517 def match_for_x_weeks @components[@pos + 2] =~ /weeks?/ end |
#match_last_day ⇒ Object
961 962 963 |
# File 'lib/nickel/construct_finder.rb', line 961 def match_last_day @components[@pos] == 'last' && @components[@pos + 1] == 'day' # last day end |
#match_last_day_monthname ⇒ Object
981 982 983 |
# File 'lib/nickel/construct_finder.rb', line 981 def match_last_day_monthname @month_index = ZDate.months_of_year.index(@components[@pos + 2]) # 1st day december end |
#match_last_day_next_month ⇒ Object
973 974 975 |
# File 'lib/nickel/construct_finder.rb', line 973 def match_last_day_next_month @components[@pos + 2] == 'next' && @components[@pos + 3] == 'month' # 1st day next month end |
#match_last_day_this_month ⇒ Object
965 966 967 |
# File 'lib/nickel/construct_finder.rb', line 965 def match_last_day_this_month @components[@pos + 2] == 'this' && @components[@pos + 3] == 'month' # 1st day this month end |
#match_monthname ⇒ Object
1162 1163 1164 1165 |
# File 'lib/nickel/construct_finder.rb', line 1162 def match_monthname # note it is important that all other uses of monthname come after indicating words such as "the third day of december"; otherwise they will be converted here @month_index = ZDate.months_of_year.index(@components[@pos]) end |
#match_next ⇒ Object
566 567 568 |
# File 'lib/nickel/construct_finder.rb', line 566 def match_next @components[@pos] == 'next' end |
#match_next_dayname ⇒ Object
580 581 582 |
# File 'lib/nickel/construct_finder.rb', line 580 def match_next_dayname @day_index = ZDate.days_of_week.index(@components[@pos + 1]) # if "next [day]" end |
#match_next_month ⇒ Object
639 640 641 642 |
# File 'lib/nickel/construct_finder.rb', line 639 def match_next_month # 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 @components[@pos + 1] =~ /months?/ end |
#match_next_week ⇒ Object
629 630 631 |
# File 'lib/nickel/construct_finder.rb', line 629 def match_next_week @components[@pos + 1] =~ /weeks?/ end |
#match_next_weekend ⇒ Object
570 571 572 |
# File 'lib/nickel/construct_finder.rb', line 570 def match_next_weekend @components[@pos + 1] == 'weekend' # "next weekend" end |
#match_next_x ⇒ Object
593 594 595 |
# File 'lib/nickel/construct_finder.rb', line 593 def match_next_x @components[@pos + 1] && ConstructFinder.digits_only?(@components[@pos + 1]) && @length = @components[@pos + 1].to_i end |
#match_next_x_days ⇒ Object
597 598 599 |
# File 'lib/nickel/construct_finder.rb', line 597 def match_next_x_days @components[@pos + 2] =~ /days?/ # "next x days" end |
#match_next_x_months ⇒ Object
613 614 615 |
# File 'lib/nickel/construct_finder.rb', line 613 def match_next_x_months @components[@pos + 2] =~ /months?/ # "next x months" end |
#match_next_x_weeks ⇒ Object
605 606 607 |
# File 'lib/nickel/construct_finder.rb', line 605 def match_next_x_weeks @components[@pos + 2] =~ /weeks?/ # "next x weeks" end |
#match_next_x_years ⇒ Object
621 622 623 |
# File 'lib/nickel/construct_finder.rb', line 621 def match_next_x_years @components[@pos + 2] =~ /years?/ # "next x years" end |
#match_now ⇒ Object
1045 1046 1047 |
# File 'lib/nickel/construct_finder.rb', line 1045 def match_now @components[@pos] == 'today' || @components[@pos] == 'now' end |
#match_now_through ⇒ Object
1049 1050 1051 |
# File 'lib/nickel/construct_finder.rb', line 1049 def match_now_through @components[@pos + 1] == 'until' || @components[@pos + 1] == 'to' || @components[@pos + 1] == 'through' # "today through" end |
#match_now_through_date ⇒ Object
1071 1072 1073 |
# File 'lib/nickel/construct_finder.rb', line 1071 def match_now_through_date @date1 = ZDate.interpret(@components[@pos + 2], @curdate) # now until 9/21 end |
#match_now_through_dayname ⇒ Object
1053 1054 1055 |
# File 'lib/nickel/construct_finder.rb', line 1053 def match_now_through_dayname @day_index = ZDate.days_of_week.index(@components[@pos + 2]) # today through thursday end |
#match_now_through_following_dayname ⇒ Object
redundant!! preprocess this out of here!
1062 1063 1064 |
# File 'lib/nickel/construct_finder.rb', line 1062 def match_now_through_following_dayname @components[@pos + 2] =~ /following|this/ && @day_index = ZDate.days_of_week.index(@components[@pos + 3]) # today through following friday end |
#match_now_through_next_dayname ⇒ Object
1087 1088 1089 |
# File 'lib/nickel/construct_finder.rb', line 1087 def match_now_through_next_dayname @components[@pos + 2] == 'next' && @day_index = ZDate.days_of_week.index(@components[@pos + 3]) # Today through next friday end |
#match_now_through_tomorrow ⇒ Object
1079 1080 1081 |
# File 'lib/nickel/construct_finder.rb', line 1079 def match_now_through_tomorrow @components[@pos + 2] == 'tomorrow' end |
#match_ordinal_dayname ⇒ Object
883 884 885 |
# File 'lib/nickel/construct_finder.rb', line 883 def match_ordinal_dayname @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 end |
#match_ordinal_dayname_monthname ⇒ Object
903 904 905 |
# File 'lib/nickel/construct_finder.rb', line 903 def match_ordinal_dayname_monthname @month_index = ZDate.months_of_year.index(@components[@pos + 2]) # second friday december end |
#match_ordinal_dayname_next_month ⇒ Object
895 896 897 |
# File 'lib/nickel/construct_finder.rb', line 895 def match_ordinal_dayname_next_month @components[@pos + 2] == 'next' && @components[@pos + 3] == 'month' # 1st monday next month end |
#match_ordinal_dayname_this_month ⇒ Object
887 888 889 |
# File 'lib/nickel/construct_finder.rb', line 887 def match_ordinal_dayname_this_month @components[@pos + 2] == 'this' && @components[@pos + 3] == 'month' # last saturday this month end |
#match_ordinal_next_month ⇒ Object
915 916 917 |
# File 'lib/nickel/construct_finder.rb', line 915 def match_ordinal_next_month @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 end |
#match_ordinal_this_month ⇒ Object
911 912 913 |
# File 'lib/nickel/construct_finder.rb', line 911 def match_ordinal_this_month @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 end |
#match_repeats ⇒ Object
376 377 378 |
# File 'lib/nickel/construct_finder.rb', line 376 def match_repeats @components[@pos] == 'repeats' end |
#match_repeats_altdaily ⇒ Object
388 389 390 |
# File 'lib/nickel/construct_finder.rb', line 388 def match_repeats_altdaily @components[@pos + 1] == 'altdaily' end |
#match_repeats_altmonthly ⇒ Object
443 444 445 |
# File 'lib/nickel/construct_finder.rb', line 443 def match_repeats_altmonthly @components[@pos + 1] == 'altmonthly' end |
#match_repeats_altmonthly_datemonthly ⇒ Object
461 462 463 |
# File 'lib/nickel/construct_finder.rb', line 461 def match_repeats_altmonthly_datemonthly @components[@pos + 2] && ConstructFinder.ordinal_only?(@components[@pos + 2]) && @date_array = [@components[@pos + 2].to_i] # repeats altmonthly 22nd end |
#match_repeats_altmonthly_daymonthly ⇒ Object
447 448 449 |
# File 'lib/nickel/construct_finder.rb', line 447 def match_repeats_altmonthly_daymonthly @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" end |
#match_repeats_altweekly_vague ⇒ Object
404 405 406 |
# File 'lib/nickel/construct_finder.rb', line 404 def match_repeats_altweekly_vague @components[@pos + 1] == 'altweekly' end |
#match_repeats_daily ⇒ Object
380 381 382 |
# File 'lib/nickel/construct_finder.rb', line 380 def match_repeats_daily @components[@pos + 1] == 'daily' end |
#match_repeats_datemonthly ⇒ Object
430 431 432 |
# File 'lib/nickel/construct_finder.rb', line 430 def match_repeats_datemonthly @components[@pos + 2] && ConstructFinder.ordinal_only?(@components[@pos + 2]) && @date_array = [@components[@pos + 2].to_i] # repeats monthly 22nd end |
#match_repeats_daymonthly ⇒ Object
416 417 418 |
# File 'lib/nickel/construct_finder.rb', line 416 def match_repeats_daymonthly @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" end |
#match_repeats_monthly ⇒ Object
412 413 414 |
# File 'lib/nickel/construct_finder.rb', line 412 def match_repeats_monthly @components[@pos + 1] == 'monthly' end |
#match_repeats_threemonthly ⇒ Object
474 475 476 |
# File 'lib/nickel/construct_finder.rb', line 474 def match_repeats_threemonthly @components[@pos + 1] == 'threemonthly' end |
#match_repeats_threemonthly_datemonthly ⇒ Object
492 493 494 |
# File 'lib/nickel/construct_finder.rb', line 492 def match_repeats_threemonthly_datemonthly @components[@pos + 2] && ConstructFinder.ordinal_only?(@components[@pos + 2]) && @date_array = [@components[@pos + 2].to_i] # repeats threemonthly 22nd end |
#match_repeats_threemonthly_daymonthly ⇒ Object
478 479 480 |
# File 'lib/nickel/construct_finder.rb', line 478 def match_repeats_threemonthly_daymonthly @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" end |
#match_repeats_weekly_vague ⇒ Object
396 397 398 |
# File 'lib/nickel/construct_finder.rb', line 396 def match_repeats_weekly_vague @components[@pos + 1] == 'weekly' end |
#match_start ⇒ Object
1173 1174 1175 |
# File 'lib/nickel/construct_finder.rb', line 1173 def match_start @components[@pos] == 'start' end |
#match_this ⇒ Object
533 534 535 |
# File 'lib/nickel/construct_finder.rb', line 533 def match_this @components[@pos] == 'this' end |
#match_this_dayname ⇒ Object
537 538 539 |
# File 'lib/nickel/construct_finder.rb', line 537 def match_this_dayname @day_index = ZDate.days_of_week.index(@components[@pos + 1]) end |
#match_this_month ⇒ Object
558 559 560 |
# File 'lib/nickel/construct_finder.rb', line 558 def match_this_month @components[@pos + 1] =~ /months?/ end |
#match_this_week ⇒ Object
550 551 552 |
# File 'lib/nickel/construct_finder.rb', line 550 def match_this_week @components[@pos + 1] =~ /weeks?/ end |
#match_through ⇒ Object
1182 1183 1184 |
# File 'lib/nickel/construct_finder.rb', line 1182 def match_through @components[@pos] == 'through' end |
#match_through_monthname ⇒ Object
1152 1153 1154 |
# File 'lib/nickel/construct_finder.rb', line 1152 def match_through_monthname @components[@pos] == 'through' && @month_index = ZDate.months_of_year.index(@components[@pos + 1]) end |
#match_time ⇒ Object
1191 1192 1193 |
# File 'lib/nickel/construct_finder.rb', line 1191 def match_time @time1 = ZTime.interpret(@components[@pos]) end |
#match_time_through_time ⇒ Object
1195 1196 1197 |
# File 'lib/nickel/construct_finder.rb', line 1195 def match_time_through_time @components[@pos + 1] =~ /^(to|through)$/ && @time2 = ZTime.interpret(@components[@pos + 2]) end |
#match_tomorrow ⇒ Object
1017 1018 1019 |
# File 'lib/nickel/construct_finder.rb', line 1017 def match_tomorrow @components[@pos] == 'tomorrow' end |
#match_tomorrow_through ⇒ Object
1021 1022 1023 |
# File 'lib/nickel/construct_finder.rb', line 1021 def match_tomorrow_through @components[@pos + 1] == 'until' || @components[@pos + 1] == 'to' || @components[@pos + 1] == 'through' # "tomorrow through" end |
#match_tomorrow_through_date ⇒ Object
1033 1034 1035 |
# File 'lib/nickel/construct_finder.rb', line 1033 def match_tomorrow_through_date @date1 = ZDate.interpret(@components[@pos + 2], @curdate) # tomorrow until 9/21 end |
#match_tomorrow_through_dayname ⇒ Object
1025 1026 1027 |
# File 'lib/nickel/construct_finder.rb', line 1025 def match_tomorrow_through_dayname @day_index = ZDate.days_of_week.index(@components[@pos + 2]) # tomorrow through thursday end |
#match_week ⇒ Object
650 651 652 |
# File 'lib/nickel/construct_finder.rb', line 650 def match_week @components[@pos] == 'week' end |
#match_week_of_date ⇒ Object
654 655 656 |
# File 'lib/nickel/construct_finder.rb', line 654 def match_week_of_date @components[@pos + 1] == 'of' && @date1 = ZDate.interpret(@components[@pos + 2], @curdate) end |
#match_week_through_date ⇒ Object
662 663 664 |
# File 'lib/nickel/construct_finder.rb', line 662 def match_week_through_date @components[@pos + 1] == 'through' && @date1 = ZDate.interpret(@components[@pos + 2], @curdate) end |
#match_x_dayname_from ⇒ Object
797 798 799 |
# File 'lib/nickel/construct_finder.rb', line 797 def match_x_dayname_from 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" end |
#match_x_dayname_from_next ⇒ Object
847 848 849 |
# File 'lib/nickel/construct_finder.rb', line 847 def match_x_dayname_from_next @components[@pos + 3] == 'next' # "two tuesdays from next" end |
#match_x_dayname_from_now ⇒ Object
801 802 803 |
# File 'lib/nickel/construct_finder.rb', line 801 def match_x_dayname_from_now @components[@pos + 3] =~ /\b(today)|(now)\b/ # if "2 tuesdays from now" end |
#match_x_dayname_from_this ⇒ Object
833 834 835 |
# File 'lib/nickel/construct_finder.rb', line 833 def match_x_dayname_from_this @components[@pos + 3] == 'this' # "two tuesdays from this" end |
#match_x_dayname_from_tomorrow ⇒ Object
811 812 813 |
# File 'lib/nickel/construct_finder.rb', line 811 def match_x_dayname_from_tomorrow @components[@pos + 3] == 'tomorrow' end |
#match_x_dayname_from_yesterday ⇒ Object
822 823 824 |
# File 'lib/nickel/construct_finder.rb', line 822 def match_x_dayname_from_yesterday @components[@pos + 3] == 'yesterday' end |
#match_x_days_from ⇒ Object
777 778 779 |
# File 'lib/nickel/construct_finder.rb', line 777 def match_x_days_from ConstructFinder.digits_only?(@components[@pos]) && @components[@pos + 1] =~ /^days?$/ && @components[@pos + 2] == 'from' && @length = @components[@pos].to_i # 3 days from end |
#match_x_days_from_dayname ⇒ Object
789 790 791 |
# File 'lib/nickel/construct_finder.rb', line 789 def match_x_days_from_dayname @day_index = ZDate.days_of_week.index(@components[@pos + 3]) # 3 days from monday, why would someone do this? end |
#match_x_days_from_now ⇒ Object
781 782 783 |
# File 'lib/nickel/construct_finder.rb', line 781 def match_x_days_from_now @components[@pos + 3] =~ /\b(now)|(today)\b/ # 3 days from today; 3 days from now end |
#match_x_hours_from_now ⇒ Object
872 873 874 |
# File 'lib/nickel/construct_finder.rb', line 872 def match_x_hours_from_now ConstructFinder.digits_only?(@components[@pos]) && @components[@pos + 1] =~ /hours?/ && @components[@pos + 2] == 'from' && @components[@pos + 3] =~ /^(today|now)$/ && @length = @components[@pos].to_i end |
#match_x_minutes_from_now ⇒ Object
861 862 863 |
# File 'lib/nickel/construct_finder.rb', line 861 def match_x_minutes_from_now ConstructFinder.digits_only?(@components[@pos]) && @components[@pos + 1] =~ /minutes?/ && @components[@pos + 2] == 'from' && @components[@pos + 3] =~ /^(today|now)$/ && @length = @components[@pos].to_i end |
#match_x_months_from ⇒ Object
725 726 727 |
# File 'lib/nickel/construct_finder.rb', line 725 def match_x_months_from ConstructFinder.digits_only?(@components[@pos]) && @components[@pos + 1] =~ /^months?$/ && @components[@pos + 2] == 'from' && @length = @components[@pos].to_i # if "x months from" end |
#match_x_months_from_dayname ⇒ Object
729 730 731 |
# File 'lib/nickel/construct_finder.rb', line 729 def match_x_months_from_dayname @day_index = ZDate.days_of_week.index(@components[@pos + 3]) # if "x months from monday" end |
#match_x_months_from_next_dayname ⇒ Object
745 746 747 |
# File 'lib/nickel/construct_finder.rb', line 745 def match_x_months_from_next_dayname @components[@pos + 3] == 'next' && @day_index = ZDate.days_of_week.index(@components[@pos + 4]) # if "x months from next monday" end |
#match_x_months_from_now ⇒ Object
761 762 763 |
# File 'lib/nickel/construct_finder.rb', line 761 def match_x_months_from_now @components[@pos + 3] =~ /\b(today)|(now)\b/ # if "x months from today" end |
#match_x_months_from_this_dayname ⇒ Object
737 738 739 |
# File 'lib/nickel/construct_finder.rb', line 737 def match_x_months_from_this_dayname @components[@pos + 3] == 'this' && @day_index = ZDate.days_of_week.index(@components[@pos + 4]) # if "x months from this monday" end |
#match_x_months_from_tomorrow ⇒ Object
753 754 755 |
# File 'lib/nickel/construct_finder.rb', line 753 def match_x_months_from_tomorrow @components[@pos + 3] == 'tomorrow' # if "x months from tomorrow" end |
#match_x_months_from_yesterday ⇒ Object
769 770 771 |
# File 'lib/nickel/construct_finder.rb', line 769 def match_x_months_from_yesterday @components[@pos + 3] == 'yesterday' # "x months from yesterday" end |
#match_x_weeks_from ⇒ Object
670 671 672 |
# File 'lib/nickel/construct_finder.rb', line 670 def match_x_weeks_from ConstructFinder.digits_only?(@components[@pos]) && @components[@pos + 1] =~ /^weeks?$/ && @components[@pos + 2] == 'from' && @length = @components[@pos].to_i # if "x weeks from" end |
#match_x_weeks_from_dayname ⇒ Object
674 675 676 |
# File 'lib/nickel/construct_finder.rb', line 674 def match_x_weeks_from_dayname @day_index = ZDate.days_of_week.index(@components[@pos + 3]) # if "x weeks from monday" end |
#match_x_weeks_from_next_dayname ⇒ Object
693 694 695 |
# File 'lib/nickel/construct_finder.rb', line 693 def match_x_weeks_from_next_dayname @components[@pos + 3] == 'next' && @day_index = ZDate.days_of_week.index(@components[@pos + 4]) # if "x weeks from next monday" end |
#match_x_weeks_from_now ⇒ Object
709 710 711 |
# File 'lib/nickel/construct_finder.rb', line 709 def match_x_weeks_from_now @components[@pos + 3] =~ /\b(today)|(now)\b/ # if "x weeks from today" end |
#match_x_weeks_from_this_dayname ⇒ Object
Reduntant, preprocess out!
683 684 685 |
# File 'lib/nickel/construct_finder.rb', line 683 def match_x_weeks_from_this_dayname @components[@pos + 3] == 'this' && @day_index = ZDate.days_of_week.index(@components[@pos + 4]) # if "x weeks from this monday" end |
#match_x_weeks_from_tomorrow ⇒ Object
701 702 703 |
# File 'lib/nickel/construct_finder.rb', line 701 def match_x_weeks_from_tomorrow @components[@pos + 3] == 'tomorrow' # if "x weeks from tomorrow" end |
#match_x_weeks_from_yesterday ⇒ Object
717 718 719 |
# File 'lib/nickel/construct_finder.rb', line 717 def match_x_weeks_from_yesterday @components[@pos + 3] == 'yesterday' # "x weeks from yesterday" end |
#reset_instance_vars ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/nickel/construct_finder.rb', line 24 def reset_instance_vars @day_index = nil @month_index = nil @week_num = nil @date_array = nil @length = nil @time1 = nil @time2 = nil @date1 = nil @date2 = nil end |
#run ⇒ Object
17 18 19 20 21 22 |
# File 'lib/nickel/construct_finder.rb', line 17 def run while @pos < @components.size big_if_on_current_word @pos += 1 end end |