Class: GData4Ruby::Base
- Inherits:
-
Object
- Object
- GData4Ruby::Base
- 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
Constant Summary collapse
- AUTH_URL =
"https://www.google.com/accounts/ClientLogin"
Instance Attribute Summary collapse
-
#debug ⇒ Object
If set to true, debug will dump all raw HTTP requests and responses.
-
#gdata_version ⇒ Object
The GData version used by the service.
-
#proxy_info ⇒ Object
Contains the ProxyInfo object for using a proxy server.
-
#use_ssl ⇒ Object
Will have the service use https instead of http.
Instance Method Summary collapse
- #create_url(path) ⇒ Object
-
#initialize(attributes = {}) ⇒ Base
constructor
Optionally, pass a hash of attributes to populate the class.
- #log(string) ⇒ Object
-
#send_request(request) ⇒ Object
Sends a request to the Google Data System.
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 = attributes[:gdata_version] ? attributes[:gdata_version] : '2.1' @use_ssl ||= false @debug ||= false end |
Instance Attribute Details
#debug ⇒ Object
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_version ⇒ Object
The GData version used by the service
82 83 84 |
# File 'lib/gdata4ruby/base.rb', line 82 def gdata_version @gdata_version end |
#proxy_info ⇒ Object
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_ssl ⇒ Object
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
#create_url(path) ⇒ Object
104 105 106 |
# File 'lib/gdata4ruby/base.rb', line 104 def create_url(path) return http_protocol + path end |
#log(string) ⇒ Object
100 101 102 |
# File 'lib/gdata4ruby/base.rb', line 100 def log(string) puts string if self.debug end |
#send_request(request) ⇒ Object
Sends a request to the Google Data System. Accepts a valid Request object, and returns a HTTPResult class.
110 111 112 113 114 |
# File 'lib/gdata4ruby/base.rb', line 110 def send_request(request) raise ArgumentError 'Request must be a GData4Ruby::Request object' if not request.is_a?Request puts "sending #{request.type} to url = #{request.url.to_s}" if @debug do_request(request) end |