class ALD::API::User

Public: A user registered on an ALD server.

Public Class Methods

new(api, data, initialized = false) click to toggle source

Internal: Create a new instance. This method is called by API#user and should not be called by library consumers.

api - The ALD::API instance this user belongs to data - a Hash containing the user’s data initialized - a Boolean indicating whether the given data is complete

or further API requests are necessary.
Calls superclass method ALD::API::CollectionEntry::new
# File lib/ALD/user.rb, line 50
def initialize(api, data, initialized = false)
  super(api, data, initialized)
end

Private Class Methods

initialized_attributes() click to toggle source

Internal: Override of CollectionEntry#initialized_attributes to enable automatic method definition, in this case id and name.

Returns an Array of attribute names (String)

# File lib/ALD/user.rb, line 81
def self.initialized_attributes
  %w[id name]
end
requested_attributes() click to toggle source

Internal: Override of CollectionEntry#requested_attributes to enable automatic method definition, in this case joined and privileges.

Returns an Array of attribute names (String)

# File lib/ALD/user.rb, line 89
def self.requested_attributes
  %w[joined privileges]
end

Public Instance Methods

mailMD5() click to toggle source

Public: Get the MD5 hash of the user’s mail adress. This method might trigger a HTTP request.

Returns a String with the hashed mail adress.

# File lib/ALD/user.rb, line 60
def mailMD5
  request unless initialized?
  @data['mail-md5']
end

Private Instance Methods

request() click to toggle source

Internal: If the data given to the constructor was not complete, use the API to request further information from the server.

Returns nothing.

# File lib/ALD/user.rb, line 71
def request
  @data = @api.request("/users/#{id}")
  @data['privileges'].map!(&:to_sym)
  @data['joined'] = DateTime.parse(@data['joined'])
end