Class: Student

Inherits:
Object
  • Object
show all
Defined in:
lib/Appolo/Models/main_model/student.rb

Constant Summary collapse

TYPE =
'students'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json_str) ⇒ Student

Returns a new instance of Student.


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/Appolo/Models/main_model/student.rb', line 14

def initialize(json_str)
  json_data = Appolo.check_json_info json_str

  @id = json_data[ModelUtils::ID]
  @number = json_data[ModelUtils::NUMBER]
  @short_name = json_data[ModelUtils::SHORT_NAME]
  @name = json_data[ModelUtils::NAME] || json_data[ModelUtils::FULL_NAME]
  @academic_email = json_data[ModelUtils::ACADEMIC_EMAIL]
  @github_username = json_data[ModelUtils::GITHUB_USERNAME]

  program_info = json_data[ModelUtils::PROGRAM]
  @program = Program.new(program_info, TYPE) unless program_info.nil?
  @avatar_url = AvatarUrl.new(json_data[ModelUtils::AVATAR_URL])
  @links = Links.new(json_data[ModelUtils::LINKS], TYPE)
end

Instance Attribute Details

#academic_emailObject (readonly)

Returns the value of attribute academic_email


11
12
13
# File 'lib/Appolo/Models/main_model/student.rb', line 11

def academic_email
  @academic_email
end

#avatar_urlObject (readonly)

Returns the value of attribute avatar_url


12
13
14
# File 'lib/Appolo/Models/main_model/student.rb', line 12

def avatar_url
  @avatar_url
end

#github_usernameObject (readonly)

Returns the value of attribute github_username


11
12
13
# File 'lib/Appolo/Models/main_model/student.rb', line 11

def github_username
  @github_username
end

#idObject (readonly)

Returns the value of attribute id


11
12
13
# File 'lib/Appolo/Models/main_model/student.rb', line 11

def id
  @id
end

Returns the value of attribute links


12
13
14
# File 'lib/Appolo/Models/main_model/student.rb', line 12

def links
  @links
end

#nameObject (readonly)

Returns the value of attribute name


11
12
13
# File 'lib/Appolo/Models/main_model/student.rb', line 11

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number


11
12
13
# File 'lib/Appolo/Models/main_model/student.rb', line 11

def number
  @number
end

#programObject (readonly)

Returns the value of attribute program


12
13
14
# File 'lib/Appolo/Models/main_model/student.rb', line 12

def program
  @program
end

#short_nameObject (readonly)

Returns the value of attribute short_name


11
12
13
# File 'lib/Appolo/Models/main_model/student.rb', line 11

def short_name
  @short_name
end

#studentsObject (readonly)

Returns the value of attribute students


12
13
14
# File 'lib/Appolo/Models/main_model/student.rb', line 12

def students
  @students
end

Instance Method Details

#to_sObject


30
31
32
# File 'lib/Appolo/Models/main_model/student.rb', line 30

def to_s
  "#{@short_name} - Number #{@number.to_s}"
end