class CrapServer::ConnectionInstance
This is the class used to bind the block that is passed to run!. Every method defined here is available inside the run! block
Attributes
address[RW]
config[RW]
handler[RW]
socket[RW]
Public Class Methods
new()
click to toggle source
# File lib/crap_server/connection_instance.rb, line 9 def initialize; end
Public Instance Methods
close()
click to toggle source
# File lib/crap_server/connection_instance.rb, line 30 def close @handler.close @socket end
close_after_write()
click to toggle source
# File lib/crap_server/connection_instance.rb, line 26 def close_after_write @handler.set_close_after_write @socket end
logger()
click to toggle source
Give access to logger class to the user
# File lib/crap_server/connection_instance.rb, line 35 def logger CrapServer::Application.send(:logger) end
run(data, &block)
click to toggle source
This method execute the block sent to run! method
# File lib/crap_server/connection_instance.rb, line 12 def run(data, &block) # Undefine the last definition if was defined undef :call if self.respond_to? :call # Define the new method to bind the block with this class. self.class.send :define_method, :call, &block self.call(data) end
write(string)
click to toggle source
Write to the client the given string
# File lib/crap_server/connection_instance.rb, line 21 def write(string) @handler.add_to_write @socket @handler.set_buffer @socket, string end