Class: User

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

Constant Summary collapse

RENDERED_AVATAR_SIZE =
'16x16'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw:) ⇒ User

Returns a new instance of User.



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

def initialize raw:
  @raw = raw
end

Class Method Details

.from_raw(raw) ⇒ Object

Jira omits the user entirely when there isn't one, so callers get nil rather than a User that raises on every question.



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

def self.from_raw raw
  raw && new(raw: raw)
end

Instance Method Details

#account_idObject



16
# File 'lib/jirametrics/user.rb', line 16

def  = @raw['accountId']

#active?Boolean

Returns:

  • (Boolean)


17
# File 'lib/jirametrics/user.rb', line 17

def active? = @raw['active']

#avatar_urlObject



25
# File 'lib/jirametrics/user.rb', line 25

def avatar_url = @raw['avatarUrls']&.[](RENDERED_AVATAR_SIZE)

#display_nameObject

Nil when there's no name to show, in either spelling. Callers want different things in that case, so the default belongs at the call site. 'name' is what older Jira called displayName, and newer versions of Cloud don't return it.



23
# File 'lib/jirametrics/user.rb', line 23

def display_name = @raw['displayName'] || @raw['name']

#email_addressObject



18
# File 'lib/jirametrics/user.rb', line 18

def email_address = @raw['emailAddress']