Class: GQTP::Backend::Synchronous::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/gqtp/backend/synchronous.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/gqtp/backend/synchronous.rb', line 62

def initialize(options={})
  @options = options
  @host = options[:host] || "127.0.0.1"
  @port = options[:port] || 10043
  begin
    @socket = TCPSocket.open(@host, @port)
  rescue SystemCallError
    raise ConnectionError.new(@host, @port, $!)
  end
  @io = IO.new(@socket)
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



61
62
63
# File 'lib/gqtp/backend/synchronous.rb', line 61

def host
  @host
end

#portObject

Returns the value of attribute port.



61
62
63
# File 'lib/gqtp/backend/synchronous.rb', line 61

def port
  @port
end

Instance Method Details

#closeObject



82
83
84
# File 'lib/gqtp/backend/synchronous.rb', line 82

def close
  @io.close
end

#read(size = nil, &block) ⇒ Object



78
79
80
# File 'lib/gqtp/backend/synchronous.rb', line 78

def read(size=nil, &block)
  @io.read(size, &block)
end

#write(*chunks, &block) ⇒ Object



74
75
76
# File 'lib/gqtp/backend/synchronous.rb', line 74

def write(*chunks, &block)
  @io.write(*chunks, &block)
end