Class: Bubble::KnockKnock::Connection

Inherits:
Object
  • Object
show all
Includes:
Bubble::KnockKnock, Exceptions, Singleton
Defined in:
lib/bubble/knock_knock/connection.rb

Overview

This class make the connection between Ruby and Google. It’s a Singleton class, turning the management of the connection easier. Just one connection will be created during all your script.

Constant Summary

Constants included from Bubble::KnockKnock

APP_NAME, VERSION

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authObject (readonly)

Returns the value of attribute auth.



17
18
19
# File 'lib/bubble/knock_knock/connection.rb', line 17

def auth
  @auth
end

#emailObject

Returns the value of attribute email.



16
17
18
# File 'lib/bubble/knock_knock/connection.rb', line 16

def email
  @email
end

#passwordObject (readonly)

Returns the value of attribute password.



17
18
19
# File 'lib/bubble/knock_knock/connection.rb', line 17

def password
  @password
end

#serviceObject

Returns the value of attribute service.



16
17
18
# File 'lib/bubble/knock_knock/connection.rb', line 16

def service
  @service
end

Class Method Details

.authObject

Retrieve the Auth Token required for authentications on all Google Services.



34
35
36
# File 'lib/bubble/knock_knock/connection.rb', line 34

def self.auth
  instance.auth
end

.connect(email, password, service) ⇒ Object

This method creates the connection. First of all it set up the environment to make the connection and after it stablish the connection with Google The service should be (i.e.):

  • cp

    Google Mail Contact Book

  • analytics

    Google Analytics

Example

require 'rubygems'
require 'knock_knock'

Bubble::KnockKnock::Connection.connect('[email protected]', 'password', 'cp')


29
30
31
# File 'lib/bubble/knock_knock/connection.rb', line 29

def self.connect(email, password, service)
  instance.connect(email, password, service)
end

Instance Method Details

#connect(email, password, service) ⇒ Object

This method creates the connection, but internally. To create the connection you must use Connection.connect() method.



39
40
41
42
43
44
45
46
# File 'lib/bubble/knock_knock/connection.rb', line 39

def connect(email, password, service)
  @email = email
  @password = password
  @service = service
    
  setup
  stablish
end