Class: Bio::BaseSpace::User

Inherits:
Model
  • Object
show all
Defined in:
lib/basespace/model/user.rb

Overview

User model.

Instance Attribute Summary

Attributes inherited from Model

#attributes, #swagger_types

Instance Method Summary collapse

Methods inherited from Model

#get_attr, #method_missing, #set_attr, #to_str

Constructor Details

#initializeUser

Create a new User instance.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/basespace/model/user.rb', line 24

def initialize
  @swagger_types = {
    'Name'            => 'str',
    'Email'           => 'str',
    'DateLastActive'  => 'datetime',
    'GravatarUrl'     => 'str',
    'HrefProjects'    => 'str',
    'DateCreated'     => 'datetime',
    'Id'              => 'str',
    'Href'            => 'str',
    'HrefRuns'        => 'str',
  }
  @attributes = {
    'Name'            => nil, # str
    'Email'           => nil, # str
    'DateLastActive'  => nil, # datetime
    'GravatarUrl'     => nil, # str
    'HrefProjects'    => nil, # str
    'DateCreated'     => nil, # datetime
    'Id'              => nil, # str
    'Href'            => nil, # str
    'HrefRuns'        => nil, # str
  }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Bio::BaseSpace::Model

Instance Method Details

#get_projects(api) ⇒ Object

Get a list of projects for the user.

api

BaseSpaceAPI instance.



64
65
66
67
# File 'lib/basespace/model/user.rb', line 64

def get_projects(api)
  is_init
  return api.get_project_by_user(get_attr('Id'))
end

#get_runs(api) ⇒ Object

Returns a list of accessible runs for the current user.

api

BaseSpaceAPI instance.



72
73
74
75
# File 'lib/basespace/model/user.rb', line 72

def get_runs(api)
  is_init
  return api.get_accessible_runs_by_user('current')
end

#is_initObject

Test if the Project instance has been initialized.

Throws ModelNotInitializedError, if the Id variable is not set.



57
58
59
# File 'lib/basespace/model/user.rb', line 57

def is_init
  raise ModelNotInitializedError.new('The user model has not been initialized yet') unless get_attr('Id')
end

#to_sObject

Return the ID and name of the user as string.



50
51
52
# File 'lib/basespace/model/user.rb', line 50

def to_s
  return "#{get_attr('Id')}: #{get_attr('Name')}"
end