Class: RaindropIo::User
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
- .current_user ⇒ Object
-
.find_by_name(name) ⇒ Object
Get user by name.
Instance Method Summary collapse
-
#collections ⇒ Object
end class << self.
Methods inherited from Base
delete, get, #initialize, #initialize_attributes, post, put, #to_h, #to_hash, #to_json
Constructor Details
This class inherits a constructor from RaindropIo::Base
Class Method Details
.current_user ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/raindrop_io/user.rb', line 5 def current_user response = get("/user") if response.status.success? && response.parse["result"] == true User.new response.parse["user"] else RaindropIo::ApiError.new response end end |
.find_by_name(name) ⇒ Object
Get user by name
16 17 18 19 20 21 22 23 |
# File 'lib/raindrop_io/user.rb', line 16 def find_by_name(name) response = get("/user/#{ERB::Util.url_encode(name)}") if response.status.success? && response.parse["result"] == true User.new response.parse["user"] else RaindropIo::ApiError.new response end end |
Instance Method Details
#collections ⇒ Object
end class << self
26 27 28 |
# File 'lib/raindrop_io/user.rb', line 26 def collections @groups[0]["collections"].map { |id| RaindropIo::Collection.find(id) } end |