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