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.
70 71 72 |
# File 'lib/ft_42.rb', line 70 def initialize(user_response) @user = user_response end |
Instance Attribute Details
#user ⇒ Object (readonly)
Returns the value of attribute user.
68 69 70 |
# File 'lib/ft_42.rb', line 68 def user @user end |
Instance Method Details
#cadet? ⇒ Boolean
116 117 118 |
# File 'lib/ft_42.rb', line 116 def cadet? !pisciner? end |
#correction_points ⇒ Object
94 95 96 |
# File 'lib/ft_42.rb', line 94 def correction_points user["correction_point"] end |
#current_projects ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/ft_42.rb', line 74 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
82 83 84 |
# File 'lib/ft_42.rb', line 82 def first_name user["first_name"] end |
#full_name ⇒ Object
90 91 92 |
# File 'lib/ft_42.rb', line 90 def full_name "#{first_name} #{last_name}" end |
#last_name ⇒ Object
86 87 88 |
# File 'lib/ft_42.rb', line 86 def last_name user["last_name"] end |
#level ⇒ Object
98 99 100 101 102 103 104 105 106 |
# File 'lib/ft_42.rb', line 98 def level if pisciner? cursus("Piscine C").first["level"] if pisciner? elsif cadet? cursus("42").first["level"] else 0 end end |
#phone ⇒ Object
108 109 110 |
# File 'lib/ft_42.rb', line 108 def phone %x(ldapsearch -Q uid=#{username} | grep mobile).split.last end |
#pisciner? ⇒ Boolean
112 113 114 |
# File 'lib/ft_42.rb', line 112 def pisciner? cursus("42").empty? end |