Class: ActionDispatch::Journey::Scanner
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | actionpack/lib/action_dispatch/journey/scanner.rb |
Class Method Summary
- .new ⇒ Scanner constructor
Instance Attribute Summary
- #eos? ⇒ Boolean readonly
Instance Method Summary
- #next_token
- #pos
- #pre_match
- #scan_setup(str)
-
#dedup_scan(regex)
private
takes advantage of
::String
@- deduping capabilities in Ruby 2.5 upwards see: bugs.ruby-lang.org/issues/13077. - #scan private
Constructor Details
.new ⇒ Scanner
# File 'actionpack/lib/action_dispatch/journey/scanner.rb', line 10
def initialize @ss = nil end
Instance Attribute Details
#eos? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'actionpack/lib/action_dispatch/journey/scanner.rb', line 18
def eos? @ss.eos? end
Instance Method Details
#dedup_scan(regex) (private)
takes advantage of ::String
@- deduping capabilities in Ruby 2.5 upwards see: bugs.ruby-lang.org/issues/13077
# File 'actionpack/lib/action_dispatch/journey/scanner.rb', line 40
def dedup_scan(regex) r = @ss.scan(regex) r ? -r : nil end
#next_token
[ GitHub ]#pos
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/scanner.rb', line 22
def pos @ss.pos end
#pre_match
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/scanner.rb', line 26
def pre_match @ss.pre_match end
#scan (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/scanner.rb', line 45
def scan case # / when @ss.skip(/\//) [:SLASH, "/"] when @ss.skip(/\(/) [:LPAREN, "("] when @ss.skip(/\)/) [:RPAREN, ")"] when @ss.skip(/\|/) [:OR, "|"] when @ss.skip(/\./) [:DOT, "."] when text = dedup_scan(/:\w+/) [:SYMBOL, text] when text = dedup_scan(/\*\w+/) [:STAR, text] when text = @ss.scan(/(?:[\w%\-~!$&'*,;=@]|\\[:()])/) text.tr! "\\", "" [:LITERAL, -text] # any char when text = dedup_scan(/./) [:LITERAL, text] end end
#scan_setup(str)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/scanner.rb', line 14
def scan_setup(str) @ss = StringScanner.new(str) end