Class: User

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_response) ⇒ User

Returns a new instance of User.



203
204
205
# File 'lib/ft_42.rb', line 203

def initialize(user_response)
  @user = user_response
end

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.



201
202
203
# File 'lib/ft_42.rb', line 201

def user
  @user
end

Instance Method Details

#cadet?Boolean

Returns:

  • (Boolean)


249
250
251
# File 'lib/ft_42.rb', line 249

def cadet?
  !pisciner?
end

#correction_pointsObject



227
228
229
# File 'lib/ft_42.rb', line 227

def correction_points
  user["correction_point"]
end

#current_projectsObject



207
208
209
210
211
212
213
# File 'lib/ft_42.rb', line 207

def current_projects
  if projects_in_progress.empty?
    return ["something, maybe..."]
  else
    return projects_in_progress.map { |in_prog| in_prog["project"]["name"] }
  end
end

#first_nameObject



215
216
217
# File 'lib/ft_42.rb', line 215

def first_name
  user["first_name"]
end

#full_nameObject



223
224
225
# File 'lib/ft_42.rb', line 223

def full_name
  "#{first_name} #{last_name}"
end

#last_nameObject



219
220
221
# File 'lib/ft_42.rb', line 219

def last_name
  user["last_name"]
end

#levelObject



231
232
233
234
235
236
237
238
239
# File 'lib/ft_42.rb', line 231

def level
  if pisciner?
    cursus("Piscine C").first["level"] if pisciner?
  elsif cadet?
    cursus("42").first["level"]
  else
    0
  end
end

#phoneObject



241
242
243
# File 'lib/ft_42.rb', line 241

def phone
  %x(ldapsearch -Q uid=#{username} | grep mobile).split.last
end

#pisciner?Boolean

Returns:

  • (Boolean)


245
246
247
# File 'lib/ft_42.rb', line 245

def pisciner?
  cursus("42").empty?
end