Class: GData::Base
- Inherits:
-
Object
- Object
- GData::Base
- Defined in:
- lib/gdata/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #authenticate(email, password) ⇒ Object
- #get(path) ⇒ Object
- #http ⇒ Object
-
#initialize(service, source, url) ⇒ Base
constructor
A new instance of Base.
- #post(path, entry) ⇒ Object
- #put(path, entry) ⇒ Object
- #request(path) ⇒ Object
Constructor Details
#initialize(service, source, url) ⇒ Base
Returns a new instance of Base.
26 27 28 29 30 |
# File 'lib/gdata/base.rb', line 26 def initialize(service, source, url) @service = service @source = source @url = url end |
Instance Attribute Details
#service ⇒ Object (readonly)
Returns the value of attribute service.
24 25 26 |
# File 'lib/gdata/base.rb', line 24 def service @service end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
24 25 26 |
# File 'lib/gdata/base.rb', line 24 def source @source end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
24 25 26 |
# File 'lib/gdata/base.rb', line 24 def url @url end |
Instance Method Details
#authenticate(email, password) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/gdata/base.rb', line 32 def authenticate(email, password) $VERBOSE = nil response = Net::HTTPS.post_form(GOOGLE_LOGIN_URL, {'Email' => email, 'Passwd' => password, 'source' => source, 'service' => service }) response.error! unless response.kind_of? Net::HTTPSuccess @headers = { 'Authorization' => "GoogleLogin auth=#{response.body.split(/=/).last}", 'Content-Type' => 'application/atom+xml' } end |
#get(path) ⇒ Object
53 54 55 |
# File 'lib/gdata/base.rb', line 53 def get(path) response, data = http.get(path, @headers) end |
#http ⇒ Object
68 69 70 71 72 |
# File 'lib/gdata/base.rb', line 68 def http conn = Net::HTTP.new(url, 80) #conn.set_debug_output $stderr conn end |
#post(path, entry) ⇒ Object
57 58 59 |
# File 'lib/gdata/base.rb', line 57 def post(path, entry) http.post(path, entry, @headers) end |
#put(path, entry) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/gdata/base.rb', line 61 def put(path, entry) h = @headers h['X-HTTP-Method-Override'] = 'PUT' # just to be nice, add the method override http.put(path, entry, h) end |
#request(path) ⇒ Object
48 49 50 51 |
# File 'lib/gdata/base.rb', line 48 def request(path) response, data = get(path) data end |