Class: Student

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

Constant Summary collapse

'students'

Instance Attribute Summary collapse

Attributes inherited from Element

#id, #links, #short_name

Instance Method Summary collapse

Methods inherited from Element

#check_json_info

Constructor Details

#initialize(json_str = nil) ⇒ Student

Returns a new instance of Student.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/Appolo/Models/main_model/student.rb', line 15

def initialize(json_str = nil)
  if json_str.nil?
    return
  end

  json_data = check_json_info json_str

  super(json_data[ModelUtils::ID],
        json_data[ModelUtils::SHORT_NAME],
        json_data[ModelUtils::LINKS],
        @@type_for_links)

  @number = json_data[ModelUtils::NUMBER]
  @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) unless program_info.nil?
  @avatar_url = AvatarUrl.new(json_data[ModelUtils::AVATAR_URL])
end

Instance Attribute Details

#academic_emailObject (readonly)

Returns the value of attribute academic_email.



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

def academic_email
  @academic_email
end

#avatar_urlObject (readonly)

Returns the value of attribute avatar_url.



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

def avatar_url
  @avatar_url
end

#github_usernameObject (readonly)

Returns the value of attribute github_username.



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

def github_username
  @github_username
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number.



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

def number
  @number
end

#programObject (readonly)

Returns the value of attribute program.



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

def program
  @program
end

#studentsObject (readonly)

Returns the value of attribute students.



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

def students
  @students
end

Instance Method Details

#to_sObject



37
38
39
# File 'lib/Appolo/Models/main_model/student.rb', line 37

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