Sha256: 023e179036351ef74a08173dfff4647b9a5e2f7f636adb1d856d7662957fcb85
Contents?: true
Size: 639 Bytes
Versions: 1
Compression:
Stored size: 639 Bytes
Contents
module 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+/ msg.skip /\s+/ end command = msg.scan /\S+/ until msg.eos? msg.skip /\s+/ if msg.peek(1) == ':' msg.pos += 1 params << msg.rest msg.terminate else params << msg.scan(/\S+/) 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.0.0 | lib/on_irc/parser.rb |