Sha256: 495eb920c80364115f6f5ee7f83175c498af5e59a56ae13566c9aa7d7770a2ea
Contents?: true
Size: 641 Bytes
Versions: 1
Compression:
Stored size: 641 Bytes
Contents
class IRC module Parser def self.parse(line) prefix = '' command = '' params = [] msg = StringScanner.new(line) if msg.peek(1) == ':' msg.pos += 1 prefix = msg.scan /\S+/u msg.skip /\s+/ end command = msg.scan /\S+/u until msg.eos? msg.skip /\s+/ if msg.peek(1) == ':' msg.pos += 1 params << msg.rest msg.terminate else params << msg.scan(/\S+/u) end end {:prefix => prefix, :command => command, :params => params} end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
on_irc-2.1.3 | lib/on_irc/parser.rb |