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.



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

def initialize(user_response)
  @user = user_response
end

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.



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

def user
  @user
end

Instance Method Details

#cadet?Boolean

Returns:

  • (Boolean)


294
295
296
# File 'lib/ft_42.rb', line 294

def cadet?
  !pisciner?
end

#correction_pointsObject



272
273
274
# File 'lib/ft_42.rb', line 272

def correction_points
  user["correction_point"]
end

#current_projectsObject



252
253
254
255
256
257
258
# File 'lib/ft_42.rb', line 252

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



260
261
262
# File 'lib/ft_42.rb', line 260

def first_name
  user["first_name"]
end

#full_nameObject



268
269
270
# File 'lib/ft_42.rb', line 268

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

#last_nameObject



264
265
266
# File 'lib/ft_42.rb', line 264

def last_name
  user["last_name"]
end

#levelObject



276
277
278
279
280
281
282
283
284
# File 'lib/ft_42.rb', line 276

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

#phoneObject



286
287
288
# File 'lib/ft_42.rb', line 286

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

#pisciner?Boolean

Returns:

  • (Boolean)


290
291
292
# File 'lib/ft_42.rb', line 290

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