Class: ClamAV::Connection
- Inherits:
-
Object
- Object
- ClamAV::Connection
- Defined in:
- lib/clamav/connection.rb
Instance Method Summary collapse
- #establish_connection ⇒ Object
-
#initialize(args) ⇒ Connection
constructor
A new instance of Connection.
- #raw_write(str) ⇒ Object
- #read_response ⇒ Object
- #send_request(str) ⇒ Object
- #write_request(str) ⇒ Object
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_connection ⇒ Object
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_response ⇒ Object
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 |