Class: Chronic::Separator
Direct Known Subclasses
SeparatorAnd, SeparatorAt, SeparatorColon, SeparatorComma, SeparatorDash, SeparatorDot, SeparatorIn, SeparatorOn, SeparatorQuote, SeparatorSlash, SeparatorSpace, SeparatorT, SeparatorW
Instance Attribute Summary
Attributes inherited from Tag
Class Method Summary collapse
-
.scan(tokens, options) ⇒ Object
Scan an Array of Token objects and apply any necessary Separator tags to each token.
-
.scan_for_and(token) ⇒ Object
token - The Token object we want to scan.
-
.scan_for_at(token) ⇒ Object
token - The Token object we want to scan.
-
.scan_for_colon(token) ⇒ Object
token - The Token object we want to scan.
-
.scan_for_commas(token) ⇒ Object
token - The Token object we want to scan.
-
.scan_for_dash(token) ⇒ Object
token - The Token object we want to scan.
-
.scan_for_dots(token) ⇒ Object
token - The Token object we want to scan.
-
.scan_for_in(token) ⇒ Object
token - The Token object we want to scan.
-
.scan_for_on(token) ⇒ Object
token - The Token object we want to scan.
-
.scan_for_quote(token) ⇒ Object
token - The Token object we want to scan.
-
.scan_for_slash(token) ⇒ Object
token - The Token object we want to scan.
-
.scan_for_space(token) ⇒ Object
token - The Token object we want to scan.
-
.scan_for_t(token) ⇒ Object
token - The Token object we want to scan.
-
.scan_for_w(token) ⇒ Object
token - The Token object we want to scan.
Instance Method Summary collapse
Methods inherited from Tag
Constructor Details
This class inherits a constructor from Chronic::Tag
Class Method Details
.scan(tokens, options) ⇒ Object
Scan an Array of Token objects and apply any necessary Separator tags to each token.
tokens - An Array of tokens to scan. options - The Hash of options specified in Chronic::parse.
Returns an Array of tokens.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/chronic/separator.rb', line 11 def self.scan(tokens, ) tokens.each do |token| if t = scan_for_commas(token) then token.tag(t); next end if t = scan_for_dots(token) then token.tag(t); next end if t = scan_for_colon(token) then token.tag(t); next end if t = scan_for_space(token) then token.tag(t); next end if t = scan_for_slash(token) then token.tag(t); next end if t = scan_for_dash(token) then token.tag(t); next end if t = scan_for_quote(token) then token.tag(t); next end if t = scan_for_at(token) then token.tag(t); next end if t = scan_for_in(token) then token.tag(t); next end if t = scan_for_on(token) then token.tag(t); next end if t = scan_for_and(token) then token.tag(t); next end if t = scan_for_t(token) then token.tag(t); next end if t = scan_for_w(token) then token.tag(t); next end end end |
.scan_for_and(token) ⇒ Object
token - The Token object we want to scan.
Returns a new SeperatorAnd Object object.
106 107 108 |
# File 'lib/chronic/separator.rb', line 106 def self.scan_for_and(token) scan_for token, SeparatorAnd, { /^and$/ => :and } end |
.scan_for_at(token) ⇒ Object
token - The Token object we want to scan.
Returns a new SeparatorAt object.
85 86 87 |
# File 'lib/chronic/separator.rb', line 85 def self.scan_for_at(token) scan_for token, SeparatorAt, { /^(at|@)$/ => :at } end |
.scan_for_colon(token) ⇒ Object
token - The Token object we want to scan.
Returns a new SeparatorColon object.
46 47 48 |
# File 'lib/chronic/separator.rb', line 46 def self.scan_for_colon(token) scan_for token, SeparatorColon, { /^:$/ => :colon } end |
.scan_for_commas(token) ⇒ Object
token - The Token object we want to scan.
Returns a new SeparatorComma object.
32 33 34 |
# File 'lib/chronic/separator.rb', line 32 def self.scan_for_commas(token) scan_for token, SeparatorComma, { /^,$/ => :comma } end |
.scan_for_dash(token) ⇒ Object
token - The Token object we want to scan.
Returns a new SeparatorDash object.
67 68 69 |
# File 'lib/chronic/separator.rb', line 67 def self.scan_for_dash(token) scan_for token, SeparatorDash, { /^-$/ => :dash } end |
.scan_for_dots(token) ⇒ Object
token - The Token object we want to scan.
Returns a new SeparatorDot object.
39 40 41 |
# File 'lib/chronic/separator.rb', line 39 def self.scan_for_dots(token) scan_for token, SeparatorDot, { /^\.$/ => :dot } end |
.scan_for_in(token) ⇒ Object
token - The Token object we want to scan.
Returns a new SeparatorIn object.
92 93 94 |
# File 'lib/chronic/separator.rb', line 92 def self.scan_for_in(token) scan_for token, SeparatorIn, { /^in$/ => :in } end |
.scan_for_on(token) ⇒ Object
token - The Token object we want to scan.
Returns a new SeparatorOn object.
99 100 101 |
# File 'lib/chronic/separator.rb', line 99 def self.scan_for_on(token) scan_for token, SeparatorOn, { /^on$/ => :on } end |
.scan_for_quote(token) ⇒ Object
token - The Token object we want to scan.
Returns a new SeparatorQuote object.
74 75 76 77 78 79 80 |
# File 'lib/chronic/separator.rb', line 74 def self.scan_for_quote(token) scan_for token, SeparatorQuote, { /^'$/ => :single_quote, /^"$/ => :double_quote } end |
.scan_for_slash(token) ⇒ Object
token - The Token object we want to scan.
Returns a new SeparatorSlash object.
60 61 62 |
# File 'lib/chronic/separator.rb', line 60 def self.scan_for_slash(token) scan_for token, SeparatorSlash, { /^\/$/ => :slash } end |
.scan_for_space(token) ⇒ Object
token - The Token object we want to scan.
Returns a new SeparatorSpace object.
53 54 55 |
# File 'lib/chronic/separator.rb', line 53 def self.scan_for_space(token) scan_for token, SeparatorSpace, { /^ $/ => :space } end |
.scan_for_t(token) ⇒ Object
token - The Token object we want to scan.
Returns a new SeperatorT Object object.
113 114 115 |
# File 'lib/chronic/separator.rb', line 113 def self.scan_for_t(token) scan_for token, SeparatorT, { /^t$/ => :T } end |
.scan_for_w(token) ⇒ Object
token - The Token object we want to scan.
Returns a new SeperatorW Object object.
120 121 122 |
# File 'lib/chronic/separator.rb', line 120 def self.scan_for_w(token) scan_for token, SeparatorW, { /^w$/ => :W } end |
Instance Method Details
#to_s ⇒ Object
124 125 126 |
# File 'lib/chronic/separator.rb', line 124 def to_s 'separator' end |