Class: Cups::Connection

Inherits:
Object
  • Object
show all
Extended by:
Gem::Deprecate
Defined in:
lib/ffi-cups/connection.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hostname, port = nil) ⇒ Connection

Returns a new instance of Connection.



7
8
9
10
# File 'lib/ffi-cups/connection.rb', line 7

def initialize(hostname, port=nil)
  @hostname = hostname
  @port = port.nil? ? 631 : port
end

Instance Attribute Details

#hostnameObject

Returns the value of attribute hostname.



5
6
7
# File 'lib/ffi-cups/connection.rb', line 5

def hostname
  @hostname
end

#portObject

Returns the value of attribute port.



5
6
7
# File 'lib/ffi-cups/connection.rb', line 5

def port
  @port
end

Class Method Details

.close(http) ⇒ Object

Closes the http connection and autoreleases the pointer Wrapper around FFI::Cups::Http#httpClose

Parameters:

  • http (Pointer)


34
35
36
# File 'lib/ffi-cups/connection.rb', line 34

def self.close(http)
  FFI::Cups::Http.httpClose(http)
end

Instance Method Details

#httpConnect2Pointer

Wrapper around FFI::Cups::Http#httpConnect2 Creates a http connection to a print server

Returns:

  • (Pointer)

    a http pointer



25
26
27
28
29
# File 'lib/ffi-cups/connection.rb', line 25

def httpConnect2
  http = FFI::Cups::Http.httpConnect2(hostname, port, nil, 0, FFI::Cups.cupsEncryption(), 1, 30000, nil)
  raise "Print server at #{hostname}:#{port} is not available" if http.null? 
  return http
end

#httpConnectEncryptPointer

Deprecated.

Use #httpConnect2 instead

Wrapper around FFI::Cups::Http#httpConnectEncrypt

Returns:

  • (Pointer)

    a http pointer



15
16
17
18
19
# File 'lib/ffi-cups/connection.rb', line 15

def httpConnectEncrypt
  http = FFI::Cups::Http.httpConnectEncrypt(hostname, port, FFI::Cups.cupsEncryption())
  raise "Print server at #{hostname}:#{port} is not available" if http.null?
  return http
end