Class: Gitwrap::User

Inherits:
GithubConnection show all
Defined in:
lib/gitwrap/users.rb

Constant Summary

Constants inherited from GithubConnection

GithubConnection::BASE_URL

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ User

Returns a new instance of User.



7
8
9
10
11
12
# File 'lib/gitwrap/users.rb', line 7

def initialize(hash)
	@name = hash['name']
	@location = hash['location']
	@email = hash['email']
	@username = hash['login']
end

Instance Attribute Details

#emailObject

Returns the value of attribute email.



3
4
5
# File 'lib/gitwrap/users.rb', line 3

def email
  @email
end

#locationObject

Returns the value of attribute location.



3
4
5
# File 'lib/gitwrap/users.rb', line 3

def location
  @location
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/gitwrap/users.rb', line 3

def name
  @name
end

#usernameObject

Returns the value of attribute username.



3
4
5
# File 'lib/gitwrap/users.rb', line 3

def username
  @username
end

Class Method Details

.fetch_all_usersObject



20
21
22
23
24
25
26
# File 'lib/gitwrap/users.rb', line 20

def self.fetch_all_users
	data = open("#{BASE_URL}users?since=#{$current_id}").read()
	data = JSON.parse(data)
	data.each {|user| $all_users << new(user)}
	$current_id += $all_users.length-1
	$all_users
end

.fetch_single_user(username) ⇒ Object



14
15
16
17
18
# File 'lib/gitwrap/users.rb', line 14

def self.fetch_single_user(username)
	data = open("#{BASE_URL}users/#{username}").read()
	data = JSON.parse(data)
	user = new(data)
end