Sha256: 28ec614901585dd77fbaa722dcea14991a48735f5bce2d54f4fbf8ced58dc5e0
Contents?: true
Size: 444 Bytes
Versions: 5
Compression:
Stored size: 444 Bytes
Contents
require 'dentaku/token' module Dentaku class TokenScanner def initialize(category, regexp, converter=nil) @category = category @regexp = %r{\A(#{ regexp })} @converter = converter end def scan(string) if m = @regexp.match(string) value = raw = m.to_s value = @converter.call(raw) if @converter return Token.new(@category, value, raw) end false end end end
Version data entries
5 entries across 5 versions & 1 rubygems