Class: Aladin::User

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json, username) ⇒ User

Returns a new instance of User.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/aladin/user.rb', line 28

def initialize(json, username)
  json = json['profile'] if json['profile']

  if json['v'] == '0.2'
    @username = username
    @name_formatted = json['name']['formatted'] if json['name']
    @avatar_url = json['avatar']['url'] if json['avatar']
    @cover_url = json['cover']['url'] if json['cover']
    @location_formatted = json['location']['formatted'] if json['location']
    @website = json['website']
    @bio = json['bio']
    @angellist_username = json['angellist']['username'] if json['angellist']
    @github_username = json['github']['username'] if json['github']
    @facebook_username = json['facebook']['username'] if json['facebook']
    @twitter_username = json['twitter']['username'] if json['twitter']
    @instagram_username = json['instagram']['username'] if json['instagram']
    @linkedin_url = json['linkedin']['url'] if json['linkedin']
    @bitcoin_address = json['bitcoin']['address'] if json['bitcoin']
    @bitmessage_address = json['bitmessage']['address'] if json['bitmessage']
    @bitcoinotc_username = json['bitcoinotc']['username'] if json['bitcoinotc']
    @pgp_fingerprint = json['pgp']['fingerprint'] if json['pgp']
    @pgp_url = json['pgp']['url'] if json['pgp']
    @schema_version = json['v']
    @orgs = parse_orgs(json['orgs'])
  else
    @username = username
    @name_formatted = json['name'] if json['name']
    @avatar_url = find_image_url(json, 'avatar')
    @cover_url = find_image_url(json, 'cover')
    @location_formatted = json['address']['addressLocality'] if json['address']
    @website = json['website'][0]['url'] if json['website'] && json['website'][0]
    @bio = json['description']
    @angellist_username = (json, 'angellist')
    @github_username = (json, 'github')
    @facebook_username = (json, 'facebook')
    @twitter_username = (json, 'twitter')
    @instagram_username = (json, 'instagram')
    @linkedin_url = (json, 'linkedin')
    @bitcoin_address = (json, 'bitcoin')
    @bitmessage_address = (json, 'bitmessage')
    @bitcoinotc_username = (json, 'bitcoinotc')
    @pgp_fingerprint = (json, 'pgp')
    @pgp_url = (json, 'pgp')['contentUrl'] if @pgp_fingerprint
    @schema_version = '0.3'
    @orgs = parse_orgs(json['orgs'])
  end
end

Instance Attribute Details

#angellist_usernameObject (readonly)

Returns the value of attribute angellist_username.



14
15
16
# File 'lib/aladin/user.rb', line 14

def angellist_username
  @angellist_username
end

#avatar_urlObject (readonly)

Returns the value of attribute avatar_url.



9
10
11
# File 'lib/aladin/user.rb', line 9

def avatar_url
  @avatar_url
end

#bioObject (readonly)

Returns the value of attribute bio.



13
14
15
# File 'lib/aladin/user.rb', line 13

def bio
  @bio
end

#bitcoin_addressObject (readonly)

Returns the value of attribute bitcoin_address.



20
21
22
# File 'lib/aladin/user.rb', line 20

def bitcoin_address
  @bitcoin_address
end

#bitcoinotc_usernameObject (readonly)

Returns the value of attribute bitcoinotc_username.



22
23
24
# File 'lib/aladin/user.rb', line 22

def bitcoinotc_username
  @bitcoinotc_username
end

#bitmessage_addressObject (readonly)

Returns the value of attribute bitmessage_address.



21
22
23
# File 'lib/aladin/user.rb', line 21

def bitmessage_address
  @bitmessage_address
end

#cover_urlObject (readonly)

Returns the value of attribute cover_url.



10
11
12
# File 'lib/aladin/user.rb', line 10

def cover_url
  @cover_url
end

#facebook_usernameObject (readonly)

Returns the value of attribute facebook_username.



16
17
18
# File 'lib/aladin/user.rb', line 16

def facebook_username
  @facebook_username
end

#github_usernameObject (readonly)

Returns the value of attribute github_username.



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

def github_username
  @github_username
end

#instagram_usernameObject (readonly)

Returns the value of attribute instagram_username.



18
19
20
# File 'lib/aladin/user.rb', line 18

def instagram_username
  @instagram_username
end

#linkedin_urlObject (readonly)

Returns the value of attribute linkedin_url.



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

def linkedin_url
  @linkedin_url
end

#location_formattedObject (readonly)

Returns the value of attribute location_formatted.



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

def location_formatted
  @location_formatted
end

#name_formattedObject (readonly)

Returns the value of attribute name_formatted.



8
9
10
# File 'lib/aladin/user.rb', line 8

def name_formatted
  @name_formatted
end

#orgsObject (readonly)

Returns the value of attribute orgs.



25
26
27
# File 'lib/aladin/user.rb', line 25

def orgs
  @orgs
end

#pgp_fingerprintObject (readonly)

Returns the value of attribute pgp_fingerprint.



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

def pgp_fingerprint
  @pgp_fingerprint
end

#pgp_urlObject (readonly)

Returns the value of attribute pgp_url.



24
25
26
# File 'lib/aladin/user.rb', line 24

def pgp_url
  @pgp_url
end

#schema_versionObject (readonly)

Returns the value of attribute schema_version.



26
27
28
# File 'lib/aladin/user.rb', line 26

def schema_version
  @schema_version
end

#twitter_usernameObject (readonly)

Returns the value of attribute twitter_username.



17
18
19
# File 'lib/aladin/user.rb', line 17

def twitter_username
  @twitter_username
end

#usernameObject (readonly)

Returns the value of attribute username.



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

def username
  @username
end

#websiteObject (readonly)

Returns the value of attribute website.



12
13
14
# File 'lib/aladin/user.rb', line 12

def website
  @website
end

Class Method Details

.from_json(json, username) ⇒ Object



3
4
5
# File 'lib/aladin/user.rb', line 3

def self.from_json(json, username)
  User.new(json, username)
end

Instance Method Details

#opennameObject



76
77
78
79
# File 'lib/aladin/user.rb', line 76

def openname
  warn '[DEPRECATION] `openname` is deprecated.  Please use `username` instead.'
  username
end