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.
# File lib/chronic/separator.rb, line 11 def self.scan(tokens, options) tokens.each do |token| if t = scan_for_commas(token) then token.tag(t); next end if t = scan_for_slash_or_dash(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 end end
token - The Token object we want to scan.
Returns a new SeperatorAnd Object object.
# File lib/chronic/separator.rb, line 64 def self.scan_for_and(token) scan_for token, SeparatorAnd, { /^and$/ => :and } end
token - The Token object we want to scan.
Returns a new SeparatorAt object.
# File lib/chronic/separator.rb, line 43 def self.scan_for_at(token) scan_for token, SeparatorAt, { /^(at|@)$/ => :at } end
token - The Token object we want to scan.
Returns a new SeparatorComma object.
# File lib/chronic/separator.rb, line 25 def self.scan_for_commas(token) scan_for token, SeparatorComma, { /^,$/ => :comma } end
token - The Token object we want to scan.
Returns a new SeparatorIn object.
# File lib/chronic/separator.rb, line 50 def self.scan_for_in(token) scan_for token, SeparatorIn, { /^in$/ => :in } end
token - The Token object we want to scan.
Returns a new SeparatorOn object.
# File lib/chronic/separator.rb, line 57 def self.scan_for_on(token) scan_for token, SeparatorOn, { /^on$/ => :on } end
token - The Token object we want to scan.
Returns a new SeparatorSlashOrDash object.
# File lib/chronic/separator.rb, line 32 def self.scan_for_slash_or_dash(token) scan_for token, SeparatorSlashOrDash, { /^-$/ => :dash, /^\/$/ => :slash } end
# File lib/chronic/separator.rb, line 68 def to_s 'separator' end