Class: Asana::User

Inherits:
Object
  • Object
show all
Defined in:
lib/asana-client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ User

Returns a new instance of User.



290
291
292
293
# File 'lib/asana-client.rb', line 290

def initialize(hash)
    self.id = hash[:id] || 0
    self.name = hash[:name] || ""
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



288
289
290
# File 'lib/asana-client.rb', line 288

def id
  @id
end

#nameObject

Returns the value of attribute name.



288
289
290
# File 'lib/asana-client.rb', line 288

def name
  @name
end

Class Method Details

.find(workspace, name) ⇒ Object



295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/asana-client.rb', line 295

def self.find(workspace, name)
    # if given string for workspace, convert to object
    if workspace.is_a? String
        workspace = Asana::Workspace.find workspace 
    end

    # check if any workspace contains the given name, and return first hit
    name.downcase!
    workspace.users.each do |user|
        if user.name.downcase.include? name
            return user
        end
    end

    nil
end

Instance Method Details

#to_sObject



312
313
314
# File 'lib/asana-client.rb', line 312

def to_s
    self.name
end