Class: ClamAV::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/clamav/connection.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Connection

Returns a new instance of Connection.



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/clamav/connection.rb', line 21

def initialize(args)
  socket  = args.fetch(:socket)  { missing_required_argument(:socket) }
  wrapper = args.fetch(:wrapper) { missing_required_argument(:wrapper) }

  if socket && wrapper
    @socket = socket
    @wrapper = wrapper
  else
    raise ArgumentError
  end
end

Instance Method Details

#establish_connectionObject



33
34
35
36
# File 'lib/clamav/connection.rb', line 33

def establish_connection
  wrapped_request = @wrapper.wrap_request("IDSESSION")
  @socket.write wrapped_request
end

#raw_write(str) ⇒ Object



52
53
54
# File 'lib/clamav/connection.rb', line 52

def raw_write(str)
  @socket.write str
end

#read_responseObject



43
44
45
# File 'lib/clamav/connection.rb', line 43

def read_response
  @wrapper.read_response(@socket)
end

#send_request(str) ⇒ Object



47
48
49
50
# File 'lib/clamav/connection.rb', line 47

def send_request(str)
  write_request(str)
  read_response
end

#write_request(str) ⇒ Object



38
39
40
41
# File 'lib/clamav/connection.rb', line 38

def write_request(str)
  wrapped_request = @wrapper.wrap_request(str)
  @socket.write wrapped_request
end