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’



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

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



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

def debug
  @debug
end

#gdata_versionObject

The GData version used by the service



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

def gdata_version
  @gdata_version
end

#proxy_infoObject

Contains the ProxyInfo object for using a proxy server



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

def proxy_info
  @proxy_info
end

#use_sslObject

Will have the service use https instead of http



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

def use_ssl
  @use_ssl
end

Instance Method Details

#authenticate(options = {}) ⇒ Object

Provides a mechanism for your service to receive credentials and authenticate



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

def authenticate(options = {})
  
end

#authenticated?Boolean

Is the service successfully authenticated and connected to google?

Returns:

  • (Boolean)


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

def authenticated?
  return false
end

#create_url(path) ⇒ Object



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

def create_url(path)
  return http_protocol + path
end

#log(string) ⇒ Object



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

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

#reauthenticate(options = {}) ⇒ Object

Allows a user to revive the authentication (connection)



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

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.



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

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