Class: Gitrob::Github::User

Inherits:
Object
  • Object
show all
Defined in:
lib/gitrob/github/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, http_client) ⇒ User

Returns a new instance of User.



7
8
9
# File 'lib/gitrob/github/user.rb', line 7

def initialize(username, http_client)
  @username, @http_client = username, http_client
end

Instance Attribute Details

#http_clientObject (readonly)

Returns the value of attribute http_client.



5
6
7
# File 'lib/gitrob/github/user.rb', line 5

def http_client
  @http_client
end

#usernameObject (readonly)

Returns the value of attribute username.



5
6
7
# File 'lib/gitrob/github/user.rb', line 5

def username
  @username
end

Instance Method Details

#avatar_urlObject



35
36
37
# File 'lib/gitrob/github/user.rb', line 35

def avatar_url
  info['avatar_url']
end

#bioObject



27
28
29
# File 'lib/gitrob/github/user.rb', line 27

def bio
  info['bio']
end

#emailObject



15
16
17
# File 'lib/gitrob/github/user.rb', line 15

def email
  info['email']
end

#locationObject



23
24
25
# File 'lib/gitrob/github/user.rb', line 23

def location
  info['location']
end

#nameObject



11
12
13
# File 'lib/gitrob/github/user.rb', line 11

def name
  info['name'] || username
end

#repositoriesObject



39
40
41
# File 'lib/gitrob/github/user.rb', line 39

def repositories
  @repositories ||= recursive_repositories
end

#save_to_database!(organization) ⇒ Object



56
57
58
# File 'lib/gitrob/github/user.rb', line 56

def save_to_database!(organization)
  self.to_model(organization).tap { |m| m.save }
end

#to_model(organization) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/gitrob/github/user.rb', line 43

def to_model(organization)
  organization.users.new(
    :username   => self.username,
    :name       => self.name,
    :website    => self.website,
    :location   => self.location,
    :email      => self.email,
    :bio        => self.bio,
    :url        => self.url,
    :avatar_url => self.avatar_url
  )
end

#urlObject



31
32
33
# File 'lib/gitrob/github/user.rb', line 31

def url
  info['html_url']
end

#websiteObject



19
20
21
# File 'lib/gitrob/github/user.rb', line 19

def website
  info['blog']
end