Class: GitHubV3API::UsersAPI
- Inherits:
-
Object
- Object
- GitHubV3API::UsersAPI
- Defined in:
- lib/github_v3_api/users_api.rb
Overview
Provides access to the GitHub Users API (developer.github.com/v3/users/)
example:
api = GitHubV3API.new(ACCESS_TOKEN)
# get list of logged-in user
a_user = api.current
#=> returns an instance of GitHubV3API::User
a_user.login
#=> 'jwilger'
Instance Method Summary collapse
-
#current ⇒ Object
Returns a single GitHubV3API::User instance representing the currently logged in user.
-
#get(username) ⇒ Object
Returns a GitHubV3API::User instance for the specified
username
. -
#initialize(connection) ⇒ UsersAPI
constructor
Typically not used directly.
Constructor Details
#initialize(connection) ⇒ UsersAPI
Typically not used directly. Use GitHubV3API#users instead.
connection
-
an instance of GitHubV3API
20 21 22 |
# File 'lib/github_v3_api/users_api.rb', line 20 def initialize(connection) @connection = connection end |
Instance Method Details
#current ⇒ Object
Returns a single GitHubV3API::User instance representing the currently logged in user
26 27 28 29 |
# File 'lib/github_v3_api/users_api.rb', line 26 def current user_data = @connection.get("/user") GitHubV3API::User.new(self, user_data) end |
#get(username) ⇒ Object
Returns a GitHubV3API::User instance for the specified username
.
username
-
the string login of the user, e.g. “octocat”
34 35 36 37 |
# File 'lib/github_v3_api/users_api.rb', line 34 def get(username) user_data = @connection.get("/users/#{username}") GitHubV3API::User.new_with_all_data(self, user_data) end |