Method: StringScanner#scan

Defined in:
lib/motion-bundler/mocks/mac_ruby-0.12/strscan.rb

#scan(pattern) ⇒ Object

Tries to match with pattern at the current position. If there’s a match, the scanner advances the “scan pointer” and returns the matched string. Otherwise, the scanner returns nil.

s = StringScanner.new('test string')
p s.scan(/\w+/)   # -> "test"
p s.scan(/\w+/)   # -> nil
p s.scan(/\s+/)   # -> " "
p s.scan(/\w+/)   # -> "string"
p s.scan(/./)     # -> nil


269
270
271
# File 'lib/motion-bundler/mocks/mac_ruby-0.12/strscan.rb', line 269

def scan(pattern)
  _scan(pattern, true, true, true)
end