Class: GData4Ruby::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/gdata4ruby/base.rb

Overview

The Base class includes the basic HTTP methods for communicating with the Google Data API. You shouldn’t use this class directly, rather access the functionality through the Service subclass.

Direct Known Subclasses

OAuthService, Service

Constant Summary collapse

@@auth_url =
"https://www.google.com/accounts/ClientLogin"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Base

Optionally, pass a hash of attributes to populate the class. If you want to use a GData version other than the default (2.1), pass a key/value pair, i.e. => ‘1.0’



88
89
90
91
92
93
94
95
96
97
# File 'lib/gdata4ruby/base.rb', line 88

def initialize(attributes = {})
  attributes.each do |key, value|
    if self.respond_to?("#{key}=")
      self.send("#{key}=", value)
    end
  end
  @gdata_version ||= '2.1'
  @use_ssl ||= false
  @debug ||= false
end

Instance Attribute Details

#debugObject

If set to true, debug will dump all raw HTTP requests and responses



78
79
80
# File 'lib/gdata4ruby/base.rb', line 78

def debug
  @debug
end

#gdata_versionObject

The GData version used by the service



81
82
83
# File 'lib/gdata4ruby/base.rb', line 81

def gdata_version
  @gdata_version
end

#proxy_infoObject

Contains the ProxyInfo object for using a proxy server



75
76
77
# File 'lib/gdata4ruby/base.rb', line 75

def proxy_info
  @proxy_info
end

#use_sslObject

Will have the service use https instead of http



84
85
86
# File 'lib/gdata4ruby/base.rb', line 84

def use_ssl
  @use_ssl
end

Instance Method Details

#authenticate(options = {}) ⇒ Object

Provides a mechanism for your service to receive credentials and authenticate



100
101
102
# File 'lib/gdata4ruby/base.rb', line 100

def authenticate(options = {})
  
end

#authenticated?Boolean

Is the service successfully authenticated and connected to google?

Returns:

  • (Boolean)


110
111
112
# File 'lib/gdata4ruby/base.rb', line 110

def authenticated?
  return false
end

#create_url(path) ⇒ Object



118
119
120
# File 'lib/gdata4ruby/base.rb', line 118

def create_url(path)
  return http_protocol + path
end

#log(string) ⇒ Object



114
115
116
# File 'lib/gdata4ruby/base.rb', line 114

def log(string)
  puts string if self.debug
end

#reauthenticate(options = {}) ⇒ Object

Allows a user to revive the authentication (connection)



105
106
107
# File 'lib/gdata4ruby/base.rb', line 105

def reauthenticate(options = {})
  
end

#send_request(request) ⇒ Object

Sends a request to the Google Data System. Accepts a valid Request object, and returns a HTTPResult class.



124
125
126
127
128
# File 'lib/gdata4ruby/base.rb', line 124

def send_request(request)
  raise ArgumentError 'Request must be a GData4Ruby::Request object' if not request.is_a?Request
  log("sending #{request.type} to url = #{request.url.to_s}")
  do_request(request)
end