Class: Grocer::Connection
- Inherits:
-
Object
- Object
- Grocer::Connection
- Defined in:
- lib/grocer/connection.rb
Instance Attribute Summary collapse
-
#certificate ⇒ Object
readonly
Returns the value of attribute certificate.
-
#gateway ⇒ Object
readonly
Returns the value of attribute gateway.
-
#passphrase ⇒ Object
readonly
Returns the value of attribute passphrase.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#retries ⇒ Object
readonly
Returns the value of attribute retries.
Instance Method Summary collapse
- #connect ⇒ Object
-
#initialize(options = {}) ⇒ Connection
constructor
A new instance of Connection.
- #read(size = nil, buf = nil) ⇒ Object
- #write(content) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Connection
Returns a new instance of Connection.
8 9 10 11 12 13 14 |
# File 'lib/grocer/connection.rb', line 8 def initialize( = {}) @certificate = .fetch(:certificate) { nil } @passphrase = .fetch(:passphrase) { nil } @gateway = .fetch(:gateway) { fail NoGatewayError } @port = .fetch(:port) { fail NoPortError } @retries = .fetch(:retries) { 3 } end |
Instance Attribute Details
#certificate ⇒ Object (readonly)
Returns the value of attribute certificate.
6 7 8 |
# File 'lib/grocer/connection.rb', line 6 def certificate @certificate end |
#gateway ⇒ Object (readonly)
Returns the value of attribute gateway.
6 7 8 |
# File 'lib/grocer/connection.rb', line 6 def gateway @gateway end |
#passphrase ⇒ Object (readonly)
Returns the value of attribute passphrase.
6 7 8 |
# File 'lib/grocer/connection.rb', line 6 def passphrase @passphrase end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
6 7 8 |
# File 'lib/grocer/connection.rb', line 6 def port @port end |
#retries ⇒ Object (readonly)
Returns the value of attribute retries.
6 7 8 |
# File 'lib/grocer/connection.rb', line 6 def retries @retries end |
Instance Method Details
#connect ⇒ Object
28 29 30 |
# File 'lib/grocer/connection.rb', line 28 def connect ssl.connect unless ssl.connected? end |
#read(size = nil, buf = nil) ⇒ Object
16 17 18 19 20 |
# File 'lib/grocer/connection.rb', line 16 def read(size = nil, buf = nil) with_connection do ssl.read(size, buf) end end |
#write(content) ⇒ Object
22 23 24 25 26 |
# File 'lib/grocer/connection.rb', line 22 def write(content) with_connection do ssl.write(content) end end |