gitlab-chronic 0.10.4 → 0.10.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.travis.yml +4 -6
  4. data/HISTORY.md +4 -0
  5. data/README.md +7 -10
  6. data/chronic.gemspec +1 -1
  7. data/lib/chronic/date.rb +7 -6
  8. data/lib/chronic/{tags/grabber.rb → grabber.rb} +10 -6
  9. data/lib/chronic/handlers.rb +2 -27
  10. data/lib/chronic/mini_date.rb +2 -2
  11. data/lib/chronic/numerizer.rb +130 -0
  12. data/lib/chronic/{tags/ordinal.rb → ordinal.rb} +8 -11
  13. data/lib/chronic/parser.rb +80 -34
  14. data/lib/chronic/{tags/pointer.rb → pointer.rb} +9 -5
  15. data/lib/chronic/{tags/repeater.rb → repeater.rb} +11 -26
  16. data/lib/chronic/repeaters/repeater_day.rb +1 -1
  17. data/lib/chronic/repeaters/repeater_day_name.rb +2 -2
  18. data/lib/chronic/repeaters/repeater_day_portion.rb +3 -3
  19. data/lib/chronic/repeaters/repeater_fortnight.rb +1 -1
  20. data/lib/chronic/repeaters/repeater_hour.rb +1 -1
  21. data/lib/chronic/repeaters/repeater_minute.rb +1 -1
  22. data/lib/chronic/repeaters/repeater_month.rb +1 -1
  23. data/lib/chronic/repeaters/repeater_month_name.rb +2 -2
  24. data/lib/chronic/repeaters/repeater_season.rb +1 -1
  25. data/lib/chronic/repeaters/repeater_second.rb +1 -1
  26. data/lib/chronic/repeaters/repeater_time.rb +2 -2
  27. data/lib/chronic/repeaters/repeater_week.rb +22 -23
  28. data/lib/chronic/repeaters/repeater_weekday.rb +2 -2
  29. data/lib/chronic/repeaters/repeater_weekend.rb +1 -1
  30. data/lib/chronic/repeaters/repeater_year.rb +1 -1
  31. data/lib/chronic/{tags/scalar.rb → scalar.rb} +10 -18
  32. data/lib/chronic/separator.rb +207 -0
  33. data/lib/chronic/{tags/sign.rb → sign.rb} +16 -2
  34. data/lib/chronic/tag.rb +7 -59
  35. data/lib/chronic/time.rb +8 -8
  36. data/lib/chronic/{tags/time_zone.rb → time_zone.rb} +1 -1
  37. data/lib/chronic/token.rb +3 -13
  38. data/lib/chronic/version.rb +1 -1
  39. data/lib/gitlab-chronic.rb +14 -18
  40. data/test/test_chronic.rb +6 -26
  41. data/test/test_handler.rb +1 -1
  42. data/test/test_numerizer.rb +86 -0
  43. data/test/test_parsing.rb +8 -306
  44. data/test/test_repeater_week.rb +0 -53
  45. data/test/test_token.rb +0 -6
  46. metadata +13 -19
  47. data/lib/chronic/definition.rb +0 -128
  48. data/lib/chronic/dictionary.rb +0 -36
  49. data/lib/chronic/repeaters/repeater_quarter.rb +0 -59
  50. data/lib/chronic/repeaters/repeater_quarter_name.rb +0 -40
  51. data/lib/chronic/tags/separator.rb +0 -123
  52. data/lib/chronic/tokenizer.rb +0 -38
  53. data/test/test_repeater_quarter.rb +0 -70
  54. data/test/test_repeater_quarter_name.rb +0 -198
@@ -10,14 +10,18 @@ module Chronic
10
10
  # Returns an Array of tokens.
11
11
  def self.scan(tokens, options)
12
12
  tokens.each do |token|
13
- token.tag scan_for(token, self, patterns, options)
13
+ if t = scan_for_all(token) then token.tag(t) end
14
14
  end
15
15
  end
16
16
 
17
- def self.patterns
18
- @@patterns ||= {
19
- 'past' => :past,
20
- /^future|in$/i => :future,
17
+ # token - The Token object we want to scan.
18
+ #
19
+ # Returns a new Pointer object.
20
+ def self.scan_for_all(token)
21
+ scan_for token, self,
22
+ {
23
+ /\bpast\b/ => :past,
24
+ /\b(?:future|in)\b/ => :future,
21
25
  }
22
26
  end
23
27
 
@@ -10,29 +10,15 @@ module Chronic
10
10
  # Returns an Array of tokens.
11
11
  def self.scan(tokens, options)
12
12
  tokens.each do |token|
13
- token.tag scan_for_quarter_names(token, options)
14
- token.tag scan_for_season_names(token, options)
15
- token.tag scan_for_month_names(token, options)
16
- token.tag scan_for_day_names(token, options)
17
- token.tag scan_for_day_portions(token, options)
18
- token.tag scan_for_times(token, options)
19
- token.tag scan_for_units(token, options)
13
+ if t = scan_for_season_names(token, options) then token.tag(t); next end
14
+ if t = scan_for_month_names(token, options) then token.tag(t); next end
15
+ if t = scan_for_day_names(token, options) then token.tag(t); next end
16
+ if t = scan_for_day_portions(token, options) then token.tag(t); next end
17
+ if t = scan_for_times(token, options) then token.tag(t); next end
18
+ if t = scan_for_units(token, options) then token.tag(t); next end
20
19
  end
21
20
  end
22
21
 
23
- # token - The Token object we want to scan.
24
- #
25
- # Returns a new Repeater object.
26
- def self.scan_for_quarter_names(token, options = {})
27
- scan_for token, RepeaterQuarterName,
28
- {
29
- /^q1$/ => :q1,
30
- /^q2$/ => :q2,
31
- /^q3$/ => :q3,
32
- /^q4$/ => :q4
33
- }, options
34
- end
35
-
36
22
  # token - The Token object we want to scan.
37
23
  #
38
24
  # Returns a new Repeater object.
@@ -74,7 +60,7 @@ module Chronic
74
60
  scan_for token, RepeaterDayName,
75
61
  {
76
62
  /^m[ou]n(day)?$/ => :monday,
77
- /^t(ue|eu|oo|u)s?(day)?$/ => :tuesday,
63
+ /^t(ue|eu|oo|u|)s?(day)?$/ => :tuesday,
78
64
  /^we(d|dnes|nds|nns)(day)?$/ => :wednesday,
79
65
  /^th(u|ur|urs|ers)(day)?$/ => :thursday,
80
66
  /^fr[iy](day)?$/ => :friday,
@@ -111,7 +97,6 @@ module Chronic
111
97
  def self.scan_for_units(token, options = {})
112
98
  {
113
99
  /^years?$/ => :year,
114
- /^q$/ => :quarter,
115
100
  /^seasons?$/ => :season,
116
101
  /^months?$/ => :month,
117
102
  /^fortnights?$/ => :fortnight,
@@ -129,7 +114,7 @@ module Chronic
129
114
  if item =~ token.word
130
115
  klass_name = 'Repeater' + symbol.to_s.capitalize
131
116
  klass = Chronic.const_get(klass_name)
132
- return klass.new(symbol, nil, options)
117
+ return klass.new(symbol, options)
133
118
  end
134
119
  end
135
120
  return nil
@@ -141,16 +126,16 @@ module Chronic
141
126
 
142
127
  # returns the width (in seconds or months) of this repeatable.
143
128
  def width
144
- raise('Repeater#width must be overridden in subclasses')
129
+ raise("Repeater#width must be overridden in subclasses")
145
130
  end
146
131
 
147
132
  # returns the next occurance of this repeatable.
148
133
  def next(pointer)
149
- raise('Start point must be set before calling #next') unless @now
134
+ raise("Start point must be set before calling #next") unless @now
150
135
  end
151
136
 
152
137
  def this(pointer)
153
- raise('Start point must be set before calling #this') unless @now
138
+ raise("Start point must be set before calling #this") unless @now
154
139
  end
155
140
 
156
141
  def to_s
@@ -2,7 +2,7 @@ module Chronic
2
2
  class RepeaterDay < Repeater #:nodoc:
3
3
  DAY_SECONDS = 86_400 # (24 * 60 * 60)
4
4
 
5
- def initialize(type, width = nil, options = {})
5
+ def initialize(type, options = {})
6
6
  super
7
7
  @current_day_start = nil
8
8
  end
@@ -2,7 +2,7 @@ module Chronic
2
2
  class RepeaterDayName < Repeater #:nodoc:
3
3
  DAY_SECONDS = 86400 # (24 * 60 * 60)
4
4
 
5
- def initialize(type, width = nil, options = {})
5
+ def initialize(type, options = {})
6
6
  super
7
7
  @current_date = nil
8
8
  end
@@ -47,7 +47,7 @@ module Chronic
47
47
 
48
48
  def symbol_to_number(sym)
49
49
  lookup = {:sunday => 0, :monday => 1, :tuesday => 2, :wednesday => 3, :thursday => 4, :friday => 5, :saturday => 6}
50
- lookup[sym] || raise('Invalid symbol specified')
50
+ lookup[sym] || raise("Invalid symbol specified")
51
51
  end
52
52
  end
53
53
  end
@@ -9,7 +9,7 @@ module Chronic
9
9
  :night => (20 * 60 * 60)..(24 * 60 * 60), # 8pm-12pm
10
10
  }
11
11
 
12
- def initialize(type, width = nil, options = {})
12
+ def initialize(type, options = {})
13
13
  super
14
14
  @current_span = nil
15
15
 
@@ -20,7 +20,7 @@ module Chronic
20
20
  @range || raise("Invalid type '#{type}' for RepeaterDayPortion")
21
21
  end
22
22
 
23
- @range || raise('Range should have been set by now')
23
+ @range || raise("Range should have been set by now")
24
24
  end
25
25
 
26
26
  def next(pointer)
@@ -84,7 +84,7 @@ module Chronic
84
84
  end
85
85
 
86
86
  def width
87
- @range || raise('Range has not been set')
87
+ @range || raise("Range has not been set")
88
88
  return @current_span.width if @current_span
89
89
  if @type.kind_of? Integer
90
90
  return (12 * 60 * 60)
@@ -2,7 +2,7 @@ module Chronic
2
2
  class RepeaterFortnight < Repeater #:nodoc:
3
3
  FORTNIGHT_SECONDS = 1_209_600 # (14 * 24 * 60 * 60)
4
4
 
5
- def initialize(type, width = nil, options = {})
5
+ def initialize(type, options = {})
6
6
  super
7
7
  @current_fortnight_start = nil
8
8
  end
@@ -2,7 +2,7 @@ module Chronic
2
2
  class RepeaterHour < Repeater #:nodoc:
3
3
  HOUR_SECONDS = 3600 # 60 * 60
4
4
 
5
- def initialize(type, width = nil, options = {})
5
+ def initialize(type, options = {})
6
6
  super
7
7
  @current_hour_start = nil
8
8
  end
@@ -2,7 +2,7 @@ module Chronic
2
2
  class RepeaterMinute < Repeater #:nodoc:
3
3
  MINUTE_SECONDS = 60
4
4
 
5
- def initialize(type, width = nil, options = {})
5
+ def initialize(type, options = {})
6
6
  super
7
7
  @current_minute_start = nil
8
8
  end
@@ -5,7 +5,7 @@ module Chronic
5
5
  MONTH_DAYS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
6
6
  MONTH_DAYS_LEAP = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
7
7
 
8
- def initialize(type, width = nil, options = {})
8
+ def initialize(type, options = {})
9
9
  super
10
10
  @current_month_start = nil
11
11
  end
@@ -16,7 +16,7 @@ module Chronic
16
16
  :december => 12
17
17
  }
18
18
 
19
- def initialize(type, width = nil, options = {})
19
+ def initialize(type, options = {})
20
20
  super
21
21
  @current_month_begin = nil
22
22
  end
@@ -45,7 +45,7 @@ module Chronic
45
45
  @current_month_begin = Chronic.construct(@now.year - 1, index)
46
46
  end
47
47
  end
48
- @current_month_begin || raise('Current month should be set by now')
48
+ @current_month_begin || raise("Current month should be set by now")
49
49
  else
50
50
  case pointer
51
51
  when :future
@@ -8,7 +8,7 @@ module Chronic
8
8
  :winter => Season.new(MiniDate.new(12,22), MiniDate.new(3,19))
9
9
  }
10
10
 
11
- def initialize(type, width = nil, options = {})
11
+ def initialize(type, options = {})
12
12
  super
13
13
  @next_season_start = nil
14
14
  @next_season_end = nil
@@ -2,7 +2,7 @@ module Chronic
2
2
  class RepeaterSecond < Repeater #:nodoc:
3
3
  SECOND_SECONDS = 1 # haha, awesome
4
4
 
5
- def initialize(type, width = nil, options = {})
5
+ def initialize(type, options = {})
6
6
  super
7
7
  @second_start = nil
8
8
  end
@@ -26,7 +26,7 @@ module Chronic
26
26
 
27
27
  end
28
28
 
29
- def initialize(time, width = nil, options = {})
29
+ def initialize(time, options = {})
30
30
  @current_time = nil
31
31
  @options = options
32
32
  time_parts = time.split(':')
@@ -109,7 +109,7 @@ module Chronic
109
109
  end
110
110
  end
111
111
 
112
- @current_time || raise('Current time cannot be nil at this point')
112
+ @current_time || raise("Current time cannot be nil at this point")
113
113
  end
114
114
 
115
115
  unless first
@@ -2,9 +2,8 @@ module Chronic
2
2
  class RepeaterWeek < Repeater #:nodoc:
3
3
  WEEK_SECONDS = 604800 # (7 * 24 * 60 * 60)
4
4
 
5
- def initialize(type, width = nil, options = {})
5
+ def initialize(type, options = {})
6
6
  super
7
- @repeater_day_name = options[:week_start] || :sunday
8
7
  @current_week_start = nil
9
8
  end
10
9
 
@@ -14,16 +13,16 @@ module Chronic
14
13
  unless @current_week_start
15
14
  case pointer
16
15
  when :future
17
- first_week_day_repeater = RepeaterDayName.new(@repeater_day_name)
18
- first_week_day_repeater.start = @now
19
- next_span = first_week_day_repeater.next(:future)
20
- @current_week_start = next_span.begin
16
+ sunday_repeater = RepeaterDayName.new(:sunday)
17
+ sunday_repeater.start = @now
18
+ next_sunday_span = sunday_repeater.next(:future)
19
+ @current_week_start = next_sunday_span.begin
21
20
  when :past
22
- first_week_day_repeater = RepeaterDayName.new(@repeater_day_name)
23
- first_week_day_repeater.start = (@now + RepeaterDay::DAY_SECONDS)
24
- first_week_day_repeater.next(:past)
25
- last_span = first_week_day_repeater.next(:past)
26
- @current_week_start = last_span.begin
21
+ sunday_repeater = RepeaterDayName.new(:sunday)
22
+ sunday_repeater.start = (@now + RepeaterDay::DAY_SECONDS)
23
+ sunday_repeater.next(:past)
24
+ last_sunday_span = sunday_repeater.next(:past)
25
+ @current_week_start = last_sunday_span.begin
27
26
  end
28
27
  else
29
28
  direction = pointer == :future ? 1 : -1
@@ -39,23 +38,23 @@ module Chronic
39
38
  case pointer
40
39
  when :future
41
40
  this_week_start = Chronic.time_class.local(@now.year, @now.month, @now.day, @now.hour) + RepeaterHour::HOUR_SECONDS
42
- first_week_day_repeater = RepeaterDayName.new(@repeater_day_name)
43
- first_week_day_repeater.start = @now
44
- this_span = first_week_day_repeater.this(:future)
45
- this_week_end = this_span.begin
41
+ sunday_repeater = RepeaterDayName.new(:sunday)
42
+ sunday_repeater.start = @now
43
+ this_sunday_span = sunday_repeater.this(:future)
44
+ this_week_end = this_sunday_span.begin
46
45
  Span.new(this_week_start, this_week_end)
47
46
  when :past
48
47
  this_week_end = Chronic.time_class.local(@now.year, @now.month, @now.day, @now.hour)
49
- first_week_day_repeater = RepeaterDayName.new(@repeater_day_name)
50
- first_week_day_repeater.start = @now
51
- last_span = first_week_day_repeater.next(:past)
52
- this_week_start = last_span.begin
48
+ sunday_repeater = RepeaterDayName.new(:sunday)
49
+ sunday_repeater.start = @now
50
+ last_sunday_span = sunday_repeater.next(:past)
51
+ this_week_start = last_sunday_span.begin
53
52
  Span.new(this_week_start, this_week_end)
54
53
  when :none
55
- first_week_day_repeater = RepeaterDayName.new(@repeater_day_name)
56
- first_week_day_repeater.start = @now
57
- last_span = first_week_day_repeater.next(:past)
58
- this_week_start = last_span.begin
54
+ sunday_repeater = RepeaterDayName.new(:sunday)
55
+ sunday_repeater.start = @now
56
+ last_sunday_span = sunday_repeater.next(:past)
57
+ this_week_start = last_sunday_span.begin
59
58
  Span.new(this_week_start, this_week_start + WEEK_SECONDS)
60
59
  end
61
60
  end
@@ -11,7 +11,7 @@ module Chronic
11
11
  :saturday => 6
12
12
  }
13
13
 
14
- def initialize(type, width = nil, options = {})
14
+ def initialize(type, options = {})
15
15
  super
16
16
  @current_weekday_start = nil
17
17
  end
@@ -80,7 +80,7 @@ module Chronic
80
80
  end
81
81
 
82
82
  def symbol_to_number(sym)
83
- DAYS[sym] || raise('Invalid symbol specified')
83
+ DAYS[sym] || raise("Invalid symbol specified")
84
84
  end
85
85
  end
86
86
  end
@@ -2,7 +2,7 @@ module Chronic
2
2
  class RepeaterWeekend < Repeater #:nodoc:
3
3
  WEEKEND_SECONDS = 172_800 # (2 * 24 * 60 * 60)
4
4
 
5
- def initialize(type, width = nil, options = {})
5
+ def initialize(type, options = {})
6
6
  super
7
7
  @current_week_start = nil
8
8
  end
@@ -2,7 +2,7 @@ module Chronic
2
2
  class RepeaterYear < Repeater #:nodoc:
3
3
  YEAR_SECONDS = 31536000 # 365 * 24 * 60 * 60
4
4
 
5
- def initialize(type, width = nil, options = {})
5
+ def initialize(type, options = {})
6
6
  super
7
7
  @current_year_start = nil
8
8
  end
@@ -14,22 +14,20 @@ module Chronic
14
14
  token = tokens[i]
15
15
  post_token = tokens[i + 1]
16
16
  if token.word =~ /^\d+$/
17
- width = token.word.length
18
17
  scalar = token.word.to_i
19
- token.tag(Scalar.new(scalar, width))
20
- token.tag(ScalarWide.new(token.word, width)) if width == 4
21
- token.tag(ScalarSubsecond.new(scalar, width)) if Chronic::Time::could_be_subsecond?(scalar, width)
22
- token.tag(ScalarSecond.new(scalar, width)) if Chronic::Time::could_be_second?(scalar, width)
23
- token.tag(ScalarMinute.new(scalar, width)) if Chronic::Time::could_be_minute?(scalar, width)
24
- token.tag(ScalarHour.new(scalar, width)) if Chronic::Time::could_be_hour?(scalar, width, options[:hours24] == false)
18
+ token.tag(Scalar.new(scalar))
19
+ token.tag(ScalarSubsecond.new(scalar)) if Chronic::Time::could_be_subsecond?(scalar)
20
+ token.tag(ScalarSecond.new(scalar)) if Chronic::Time::could_be_second?(scalar)
21
+ token.tag(ScalarMinute.new(scalar)) if Chronic::Time::could_be_minute?(scalar)
22
+ token.tag(ScalarHour.new(scalar)) if Chronic::Time::could_be_hour?(scalar)
25
23
  unless post_token and DAY_PORTIONS.include?(post_token.word)
26
- token.tag(ScalarDay.new(scalar, width)) if Chronic::Date::could_be_day?(scalar, width)
27
- token.tag(ScalarMonth.new(scalar, width)) if Chronic::Date::could_be_month?(scalar, width)
28
- if Chronic::Date::could_be_year?(scalar, width)
24
+ token.tag(ScalarDay.new(scalar)) if Chronic::Date::could_be_day?(scalar)
25
+ token.tag(ScalarMonth.new(scalar)) if Chronic::Date::could_be_month?(scalar)
26
+ if Chronic::Date::could_be_year?(scalar)
29
27
  year = Chronic::Date::make_year(scalar, options[:ambiguous_year_future_bias])
30
- token.tag(ScalarYear.new(year.to_i, width))
28
+ token.tag(ScalarYear.new(year.to_i))
31
29
  end
32
- end
30
+ end
33
31
  end
34
32
  end
35
33
  end
@@ -39,12 +37,6 @@ module Chronic
39
37
  end
40
38
  end
41
39
 
42
- class ScalarWide < Scalar #:nodoc:
43
- def to_s
44
- super << '-wide-' << @type.to_s
45
- end
46
- end
47
-
48
40
  class ScalarSubsecond < Scalar #:nodoc:
49
41
  def to_s
50
42
  super << '-subsecond-' << @type.to_s
@@ -0,0 +1,207 @@
1
+ module Chronic
2
+ class Separator < Tag
3
+
4
+ # Scan an Array of Token objects and apply any necessary Separator
5
+ # tags to each token.
6
+ #
7
+ # tokens - An Array of tokens to scan.
8
+ # options - The Hash of options specified in Chronic::parse.
9
+ #
10
+ # Returns an Array of tokens.
11
+ def self.scan(tokens, options)
12
+ tokens.each do |token|
13
+ if t = scan_for_commas(token) then token.tag(t); next end
14
+ if t = scan_for_dots(token) then token.tag(t); next end
15
+ if t = scan_for_colon(token) then token.tag(t); next end
16
+ if t = scan_for_space(token) then token.tag(t); next end
17
+ if t = scan_for_slash(token) then token.tag(t); next end
18
+ if t = scan_for_dash(token) then token.tag(t); next end
19
+ if t = scan_for_quote(token) then token.tag(t); next end
20
+ if t = scan_for_at(token) then token.tag(t); next end
21
+ if t = scan_for_in(token) then token.tag(t); next end
22
+ if t = scan_for_on(token) then token.tag(t); next end
23
+ if t = scan_for_and(token) then token.tag(t); next end
24
+ if t = scan_for_t(token) then token.tag(t); next end
25
+ if t = scan_for_w(token) then token.tag(t); next end
26
+ end
27
+ end
28
+
29
+ # token - The Token object we want to scan.
30
+ #
31
+ # Returns a new SeparatorComma object.
32
+ def self.scan_for_commas(token)
33
+ scan_for token, SeparatorComma, { /^,$/ => :comma }
34
+ end
35
+
36
+ # token - The Token object we want to scan.
37
+ #
38
+ # Returns a new SeparatorDot object.
39
+ def self.scan_for_dots(token)
40
+ scan_for token, SeparatorDot, { /^\.$/ => :dot }
41
+ end
42
+
43
+ # token - The Token object we want to scan.
44
+ #
45
+ # Returns a new SeparatorColon object.
46
+ def self.scan_for_colon(token)
47
+ scan_for token, SeparatorColon, { /^:$/ => :colon }
48
+ end
49
+
50
+ # token - The Token object we want to scan.
51
+ #
52
+ # Returns a new SeparatorSpace object.
53
+ def self.scan_for_space(token)
54
+ scan_for token, SeparatorSpace, { /^ $/ => :space }
55
+ end
56
+
57
+ # token - The Token object we want to scan.
58
+ #
59
+ # Returns a new SeparatorSlash object.
60
+ def self.scan_for_slash(token)
61
+ scan_for token, SeparatorSlash, { /^\/$/ => :slash }
62
+ end
63
+
64
+ # token - The Token object we want to scan.
65
+ #
66
+ # Returns a new SeparatorDash object.
67
+ def self.scan_for_dash(token)
68
+ scan_for token, SeparatorDash, { /^-$/ => :dash }
69
+ end
70
+
71
+ # token - The Token object we want to scan.
72
+ #
73
+ # Returns a new SeparatorQuote object.
74
+ def self.scan_for_quote(token)
75
+ scan_for token, SeparatorQuote,
76
+ {
77
+ /^'$/ => :single_quote,
78
+ /^"$/ => :double_quote
79
+ }
80
+ end
81
+
82
+ # token - The Token object we want to scan.
83
+ #
84
+ # Returns a new SeparatorAt object.
85
+ def self.scan_for_at(token)
86
+ scan_for token, SeparatorAt, { /^(at|@)$/ => :at }
87
+ end
88
+
89
+ # token - The Token object we want to scan.
90
+ #
91
+ # Returns a new SeparatorIn object.
92
+ def self.scan_for_in(token)
93
+ scan_for token, SeparatorIn, { /^in$/ => :in }
94
+ end
95
+
96
+ # token - The Token object we want to scan.
97
+ #
98
+ # Returns a new SeparatorOn object.
99
+ def self.scan_for_on(token)
100
+ scan_for token, SeparatorOn, { /^on$/ => :on }
101
+ end
102
+
103
+ # token - The Token object we want to scan.
104
+ #
105
+ # Returns a new SeperatorAnd Object object.
106
+ def self.scan_for_and(token)
107
+ scan_for token, SeparatorAnd, { /^and$/ => :and }
108
+ end
109
+
110
+ # token - The Token object we want to scan.
111
+ #
112
+ # Returns a new SeperatorT Object object.
113
+ def self.scan_for_t(token)
114
+ scan_for token, SeparatorT, { /^t$/ => :T }
115
+ end
116
+
117
+ # token - The Token object we want to scan.
118
+ #
119
+ # Returns a new SeperatorW Object object.
120
+ def self.scan_for_w(token)
121
+ scan_for token, SeparatorW, { /^w$/ => :W }
122
+ end
123
+
124
+ def to_s
125
+ 'separator'
126
+ end
127
+ end
128
+
129
+ class SeparatorComma < Separator #:nodoc:
130
+ def to_s
131
+ super << '-comma'
132
+ end
133
+ end
134
+
135
+ class SeparatorDot < Separator #:nodoc:
136
+ def to_s
137
+ super << '-dot'
138
+ end
139
+ end
140
+
141
+ class SeparatorColon < Separator #:nodoc:
142
+ def to_s
143
+ super << '-colon'
144
+ end
145
+ end
146
+
147
+ class SeparatorSpace < Separator #:nodoc:
148
+ def to_s
149
+ super << '-space'
150
+ end
151
+ end
152
+
153
+ class SeparatorSlash < Separator #:nodoc:
154
+ def to_s
155
+ super << '-slash'
156
+ end
157
+ end
158
+
159
+ class SeparatorDash < Separator #:nodoc:
160
+ def to_s
161
+ super << '-dash'
162
+ end
163
+ end
164
+
165
+ class SeparatorQuote < Separator #:nodoc:
166
+ def to_s
167
+ super << '-quote-' << @type.to_s
168
+ end
169
+ end
170
+
171
+ class SeparatorAt < Separator #:nodoc:
172
+ def to_s
173
+ super << '-at'
174
+ end
175
+ end
176
+
177
+ class SeparatorIn < Separator #:nodoc:
178
+ def to_s
179
+ super << '-in'
180
+ end
181
+ end
182
+
183
+ class SeparatorOn < Separator #:nodoc:
184
+ def to_s
185
+ super << '-on'
186
+ end
187
+ end
188
+
189
+ class SeparatorAnd < Separator #:nodoc:
190
+ def to_s
191
+ super << '-and'
192
+ end
193
+ end
194
+
195
+ class SeparatorT < Separator #:nodoc:
196
+ def to_s
197
+ super << '-T'
198
+ end
199
+ end
200
+
201
+ class SeparatorW < Separator #:nodoc:
202
+ def to_s
203
+ super << '-W'
204
+ end
205
+ end
206
+
207
+ end