Class: IRC::Client::Dispatcher::ConnectionDispatcher::Data
- Defined in:
- lib/failirc/client/dispatcher/connectiondispatcher.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#dispatcher ⇒ Object
readonly
Returns the value of attribute dispatcher.
Instance Method Summary collapse
- #[](socket) ⇒ Object
- #clear(socket) ⇒ Object
- #delete(socket) ⇒ Object
- #each(&block) ⇒ Object
- #empty?(socket = nil) ⇒ Boolean
- #first(socket) ⇒ Object
-
#initialize(dispatcher) ⇒ Data
constructor
A new instance of Data.
- #last(socket) ⇒ Object
- #pop(socket) ⇒ Object
- #push(socket, string) ⇒ Object
Constructor Details
#initialize(dispatcher) ⇒ Data
Returns a new instance of Data.
82 83 84 85 86 87 |
# File 'lib/failirc/client/dispatcher/connectiondispatcher.rb', line 82 def initialize (dispatcher) @client = dispatcher.client @dispatcher = dispatcher @data = ThreadSafeHash.new end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
80 81 82 |
# File 'lib/failirc/client/dispatcher/connectiondispatcher.rb', line 80 def client @client end |
#dispatcher ⇒ Object (readonly)
Returns the value of attribute dispatcher.
80 81 82 |
# File 'lib/failirc/client/dispatcher/connectiondispatcher.rb', line 80 def dispatcher @dispatcher end |
Instance Method Details
#[](socket) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/failirc/client/dispatcher/connectiondispatcher.rb', line 89 def [] (socket) if socket.is_a?(Server) socket = socket.socket end if !@data[socket].is_a?(Array) @data[socket] = [] end @data[socket] end |
#clear(socket) ⇒ Object
123 124 125 |
# File 'lib/failirc/client/dispatcher/connectiondispatcher.rb', line 123 def clear (socket) self[socket].clear end |
#delete(socket) ⇒ Object
127 128 129 130 131 132 133 |
# File 'lib/failirc/client/dispatcher/connectiondispatcher.rb', line 127 def delete (socket) if socket.is_a?(Server) socket = socket.socket end @data.delete(socket) end |
#each(&block) ⇒ Object
159 160 161 |
# File 'lib/failirc/client/dispatcher/connectiondispatcher.rb', line 159 def each (&block) @data.each_key &block end |
#empty?(socket = nil) ⇒ Boolean
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/failirc/client/dispatcher/connectiondispatcher.rb', line 143 def empty? (socket=nil) if socket if socket.is_a?(Server) socket = socket.socket end if @data.has_key?(socket) return @data[socket].empty? else return true end else return @data.empty? end end |
#first(socket) ⇒ Object
135 136 137 |
# File 'lib/failirc/client/dispatcher/connectiondispatcher.rb', line 135 def first (socket) self[socket].first end |
#last(socket) ⇒ Object
139 140 141 |
# File 'lib/failirc/client/dispatcher/connectiondispatcher.rb', line 139 def last (socket) self[socket].last end |
#pop(socket) ⇒ Object
119 120 121 |
# File 'lib/failirc/client/dispatcher/connectiondispatcher.rb', line 119 def pop (socket) self[socket].shift end |
#push(socket, string) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/failirc/client/dispatcher/connectiondispatcher.rb', line 101 def push (socket, string) if string.is_a?(String) string.lstrip! end if string == :EOC if socket.is_a?(Client) || socket.is_a?(User) socket = socket.socket end dispatcher.disconnecting.push({ :server => client.server(socket), :output => self[socket] }) end if (string && !string.empty?) || self[socket].last == :EOC self[socket].push(string) end end |