Class: Grocer::Connection

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Connection

Returns a new instance of Connection.



11
12
13
14
15
16
17
# File 'lib/grocer/connection.rb', line 11

def initialize(options = {})
  @certificate = options.fetch(:certificate) { fail NoCertificateError }
  @gateway = options.fetch(:gateway) { fail NoGatewayError }
  @port = options.fetch(:port) { fail NoPortError }
  @passphrase = options.fetch(:passphrase) { nil }
  @retries = options.fetch(:retries) { 3 }
end

Instance Attribute Details

#certificateObject (readonly)

Returns the value of attribute certificate.



9
10
11
# File 'lib/grocer/connection.rb', line 9

def certificate
  @certificate
end

#gatewayObject (readonly)

Returns the value of attribute gateway.



9
10
11
# File 'lib/grocer/connection.rb', line 9

def gateway
  @gateway
end

#passphraseObject (readonly)

Returns the value of attribute passphrase.



9
10
11
# File 'lib/grocer/connection.rb', line 9

def passphrase
  @passphrase
end

#portObject (readonly)

Returns the value of attribute port.



9
10
11
# File 'lib/grocer/connection.rb', line 9

def port
  @port
end

#retriesObject (readonly)

Returns the value of attribute retries.



9
10
11
# File 'lib/grocer/connection.rb', line 9

def retries
  @retries
end

Instance Method Details

#read(size = nil, buf = nil) ⇒ Object



19
20
21
22
23
# File 'lib/grocer/connection.rb', line 19

def read(size = nil, buf = nil)
  with_connection do
    ssl.read(size, buf)
  end
end

#write(content) ⇒ Object



25
26
27
28
29
# File 'lib/grocer/connection.rb', line 25

def write(content)
  with_connection do
    ssl.write(content)
  end
end