Module: Moped::Connection::Socket::Connectable
Overview
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
- #host ⇒ Object readonly
- #port ⇒ Object readonly
Class Method Summary collapse
-
.included(klass) ⇒ Object
Bring in the class methods when included.
Instance Method Summary collapse
-
#alive? ⇒ true, false
Is the socket connection alive?.
-
#read(length) ⇒ Object
Read from the TCP socket.
-
#write(*args) ⇒ Integer
Write to the socket.
Instance Attribute Details
#host ⇒ Object (readonly)
6 7 8 |
# File 'lib/moped/connection/socket/connectable.rb', line 6 def host @host end |
#port ⇒ Object (readonly)
6 7 8 |
# File 'lib/moped/connection/socket/connectable.rb', line 6 def port @port end |
Class Method Details
.included(klass) ⇒ Object
Bring in the class methods when included.
34 35 36 |
# File 'lib/moped/connection/socket/connectable.rb', line 34 def self.included(klass) klass.send(:extend, ClassMethods) end |
Instance Method Details
#alive? ⇒ true, false
Is the socket connection alive?
16 17 18 19 20 21 22 23 24 |
# File 'lib/moped/connection/socket/connectable.rb', line 16 def alive? if Kernel::select([ self ], nil, [ self ], 0) !eof? rescue false else true end rescue IOError false end |
#read(length) ⇒ Object
Read from the TCP socket.
45 46 47 48 |
# File 'lib/moped/connection/socket/connectable.rb', line 45 def read(length) check_if_alive! handle_socket_errors { super } end |
#write(*args) ⇒ Integer
Write to the socket.
60 61 62 63 |
# File 'lib/moped/connection/socket/connectable.rb', line 60 def write(*args) check_if_alive! handle_socket_errors { super } end |