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.
203 204 205 |
# File 'lib/ft_42.rb', line 203 def initialize(user_response) @user = user_response end |
Instance Attribute Details
#user ⇒ Object (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
249 250 251 |
# File 'lib/ft_42.rb', line 249 def cadet? !pisciner? end |
#correction_points ⇒ Object
227 228 229 |
# File 'lib/ft_42.rb', line 227 def correction_points user["correction_point"] end |
#current_projects ⇒ Object
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_name ⇒ Object
215 216 217 |
# File 'lib/ft_42.rb', line 215 def first_name user["first_name"] end |
#full_name ⇒ Object
223 224 225 |
# File 'lib/ft_42.rb', line 223 def full_name "#{first_name} #{last_name}" end |
#last_name ⇒ Object
219 220 221 |
# File 'lib/ft_42.rb', line 219 def last_name user["last_name"] end |
#level ⇒ Object
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 |
#phone ⇒ Object
241 242 243 |
# File 'lib/ft_42.rb', line 241 def phone %x(ldapsearch -Q uid=#{username} | grep mobile).split.last end |
#pisciner? ⇒ Boolean
245 246 247 |
# File 'lib/ft_42.rb', line 245 def pisciner? cursus("42").empty? end |