Sha256: 2a83908f541abee11ce9ab3bc80edc5bd5dd1f9c0c95781d6739fe8f3595b957
Contents?: true
Size: 638 Bytes
Versions: 5
Compression:
Stored size: 638 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+/ 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
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
on_irc-2.1.5 | lib/on_irc/parser.rb |
on_irc-2.1.4 | lib/on_irc/parser.rb |
on_irc-2.1.1 | lib/on_irc/parser.rb |
on_irc-2.1.0 | lib/on_irc/parser.rb |
on_irc-2.0.1 | lib/on_irc/parser.rb |