Class: User
- Inherits:
-
Object
- Object
- User
- Defined in:
- lib/ft_42.rb
Instance Attribute Summary collapse
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #cadet? ⇒ Boolean
- #correction_points ⇒ Object
- #current_projects ⇒ Object
- #first_name ⇒ Object
- #full_name ⇒ Object
-
#initialize(user_response) ⇒ User
constructor
A new instance of User.
- #last_name ⇒ Object
- #level ⇒ Object
- #phone ⇒ Object
- #pisciner? ⇒ Boolean
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
#user ⇒ Object (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
294 295 296 |
# File 'lib/ft_42.rb', line 294 def cadet? !pisciner? end |
#correction_points ⇒ Object
272 273 274 |
# File 'lib/ft_42.rb', line 272 def correction_points user["correction_point"] end |
#current_projects ⇒ Object
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_name ⇒ Object
260 261 262 |
# File 'lib/ft_42.rb', line 260 def first_name user["first_name"] end |
#full_name ⇒ Object
268 269 270 |
# File 'lib/ft_42.rb', line 268 def full_name "#{first_name} #{last_name}" end |
#last_name ⇒ Object
264 265 266 |
# File 'lib/ft_42.rb', line 264 def last_name user["last_name"] end |
#level ⇒ Object
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 |
#phone ⇒ Object
286 287 288 |
# File 'lib/ft_42.rb', line 286 def phone %x(ldapsearch -Q uid=#{username} | grep mobile).split.last end |
#pisciner? ⇒ Boolean
290 291 292 |
# File 'lib/ft_42.rb', line 290 def pisciner? cursus("42").empty? end |