Sha256: f307ce5abe2487509ec7268248070bd169d9bff77156249fb65ff5307a172b28
Contents?: true
Size: 724 Bytes
Versions: 3
Compression:
Stored size: 724 Bytes
Contents
module Marvin::IRC class Event attr_accessor :keys, :name, :raw_arguments def initialize(name, *args) self.name = name.to_sym self.keys = args.flatten.map { |k| k.to_sym } end def to_hash return {} unless self.raw_arguments results = {} values = self.raw_arguments.to_a last_index = self.keys.size - 1 self.keys.each_with_index do |key, i| results[key] = (i == last_index ? values.join(" ").strip : values.shift) end return results end def inspect "#<Marvin::IRC::Event name=#{self.name} attributes=[#{keys * ","}] >" end def to_incoming_event_name :"incoming_#{self.name}" end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
Sutto-marvin-0.1.0.20081016 | lib/marvin/irc/event.rb |
Sutto-marvin-0.1.20081115 | lib/marvin/irc/event.rb |
jeffrafter-marvin-0.1.20081115 | lib/marvin/irc/event.rb |