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