Class: Weibo2::Interface::Base
- Inherits:
-
Object
- Object
- Weibo2::Interface::Base
- Defined in:
- lib/weibo2/interface/base.rb
Overview
The Base class of API
Direct Known Subclasses
Account, Comments, Favorites, Friendships, Register, Search, Statuses, Suggestions, Tags, Trends, Users
Instance Method Summary collapse
- #get(path, opts = {}, &block) ⇒ Object
-
#initialize(client) ⇒ Base
constructor
A new instance of Base.
- #post(path, opts = {}, &block) ⇒ Object
- #request(verb, path, opts = {}, &block) ⇒ Object
Constructor Details
#initialize(client) ⇒ Base
Returns a new instance of Base.
6 7 8 |
# File 'lib/weibo2/interface/base.rb', line 6 def initialize(client) @client = client end |
Instance Method Details
#get(path, opts = {}, &block) ⇒ Object
22 23 24 |
# File 'lib/weibo2/interface/base.rb', line 22 def get(path, opts={}, &block) request(:get, path, opts, &block) end |
#post(path, opts = {}, &block) ⇒ Object
26 27 28 |
# File 'lib/weibo2/interface/base.rb', line 26 def post(path, opts={}, &block) request(:post, path, opts, &block) end |
#request(verb, path, opts = {}, &block) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/weibo2/interface/base.rb', line 10 def request(verb, path, opts={}, &block) unless @client. raise "I can't find a valid access_token. Forgot to get it or expired?" end response = @client.token.request(verb, path, opts, &block) if response.error raise Error.new(response) end response end |