Scan an Array of {Token}s and apply any necessary Separator tags to each token
@param [Array<Token>] tokens Array of tokens to scan @param [Hash] options Options specified in {Chronic.parse} @return [Array] list of tokens
# File lib/chronic/separator.rb, line 10 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 end end
@param [Token] token @return [SeparatorAt, nil]
# File lib/chronic/separator.rb, line 38 def self.scan_for_at(token) scan_for token, SeparatorAt, { %r^(at|@)$/ => :at } end
@param [Token] token @return [SeparatorComma, nil]
# File lib/chronic/separator.rb, line 22 def self.scan_for_commas(token) scan_for token, SeparatorComma, { %r^,$/ => :comma } end
@param [Token] token @return [SeparatorIn, nil]
# File lib/chronic/separator.rb, line 44 def self.scan_for_in(token) scan_for token, SeparatorIn, { %r^in$/ => :in } end
@param [Token] token @return [SeparatorOn, nil]
# File lib/chronic/separator.rb, line 50 def self.scan_for_on(token) scan_for token, SeparatorOn, { %r^on$/ => :on } end
@param [Token] token @return [SeparatorSlashOrDash, nil]
# File lib/chronic/separator.rb, line 28 def self.scan_for_slash_or_dash(token) scan_for token, SeparatorSlashOrDash, { %r^-$/ => :dash, %r^\/$/ => :slash } end
# File lib/chronic/separator.rb, line 54 def to_s 'separator' end