123456789_123456789_123456789_123456789_123456789_

Class: ActionDispatch::Journey::Scanner

Do not use. This class is for internal use only.
Relationships & Source Files
Namespace Children
Classes:
Inherits: Object
Defined in: actionpack/lib/action_dispatch/journey/scanner.rb

Constant Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.newScanner

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/scanner.rb', line 28

def initialize
  @scanner = nil
  @length = nil
end

Instance Attribute Details

#next_byte_is_not_a_token?Boolean (readonly, private)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/scanner.rb', line 69

def next_byte_is_not_a_token?
  !STATIC_TOKENS[@scanner.string.getbyte(@scanner.pos + 1)]
end

Instance Method Details

#last_literal

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/scanner.rb', line 48

def last_literal
  last_str = @scanner.string.byteslice(@scanner.pos - @length, @length)
  last_str.tr! "\\", ""
  -last_str
end

#last_string

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/scanner.rb', line 44

def last_string
  -@scanner.string.byteslice(@scanner.pos - @length, @length)
end

#next_token

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/scanner.rb', line 37

def next_token
  return if @scanner.eos?

  until token = scan || @scanner.eos?; end
  token
end

#scan (private)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/scanner.rb', line 55

def scan
  next_byte = @scanner.peek_byte
  case
  when (token = STATIC_TOKENS[next_byte]) && (token != :SYMBOL || next_byte_is_not_a_token?)
    @scanner.pos += 1
    @length = @scanner.skip(/\w+/).to_i + 1 if token == :SYMBOL || token == :STAR
    token
  when @length = @scanner.skip(/(?:[\w%\-~!$&'*,;=@]|\\[:()])/)
    :LITERAL
  when @length = @scanner.skip(/./)
    :LITERAL
  end
end

#scan_setup(str)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/journey/scanner.rb', line 33

def scan_setup(str)
  @scanner = Scanner.new(str)
end