Class: User

Inherits:
Object
  • Object
show all
Defined in:
lib/ft_42.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#userObject (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

Returns:

  • (Boolean)


122
123
124
# File 'lib/ft_42.rb', line 122

def cadet?
  !pisciner?
end

#correction_pointsObject



100
101
102
# File 'lib/ft_42.rb', line 100

def correction_points
  user["correction_point"]
end

#current_projectsObject



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_nameObject



88
89
90
# File 'lib/ft_42.rb', line 88

def first_name
  user["first_name"]
end

#full_nameObject



96
97
98
# File 'lib/ft_42.rb', line 96

def full_name
  "#{first_name} #{last_name}"
end

#last_nameObject



92
93
94
# File 'lib/ft_42.rb', line 92

def last_name
  user["last_name"]
end

#levelObject



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

#phoneObject



114
115
116
# File 'lib/ft_42.rb', line 114

def phone
  %x(ldapsearch -Q uid=#{username} | grep mobile).split.last
end

#pisciner?Boolean

Returns:

  • (Boolean)


118
119
120
# File 'lib/ft_42.rb', line 118

def pisciner?
  cursus("42").empty?
end