Class: ActionDispatch::Journey::Scanner

Inherits:
Object
  • Object
show all
Defined in:
lib/action_dispatch/journey/scanner.rb

Overview

:nodoc:

Defined Under Namespace

Classes: Scanner

Constant Summary collapse

STATIC_TOKENS =
Array.new(150)

Instance Method Summary collapse

Constructor Details

#initializeScanner

Returns a new instance of Scanner.



28
29
30
31
# File 'lib/action_dispatch/journey/scanner.rb', line 28

def initialize
  @scanner = nil
  @length = nil
end

Instance Method Details

#last_literalObject



48
49
50
51
52
# File '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_stringObject



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

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

#next_tokenObject



37
38
39
40
41
42
# File 'lib/action_dispatch/journey/scanner.rb', line 37

def next_token
  return if @scanner.eos?

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

#scan_setup(str) ⇒ Object



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

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