Class: Classes
- Defined in:
- lib/Appolo/Models/main_model/classes.rb
Constant Summary collapse
- @@type_of_links =
'classes'
Instance Attribute Summary collapse
-
#course_unit_id ⇒ Object
readonly
Returns the value of attribute course_unit_id.
-
#course_unit_short_name ⇒ Object
readonly
Returns the value of attribute course_unit_short_name.
-
#full_name ⇒ Object
readonly
Returns the value of attribute full_name.
-
#lective_semester_id ⇒ Object
readonly
Returns the value of attribute lective_semester_id.
-
#main_teacher ⇒ Object
readonly
Returns the value of attribute main_teacher.
-
#main_teacher_id ⇒ Object
readonly
Returns the value of attribute main_teacher_id.
-
#main_teacher_short_name ⇒ Object
readonly
Returns the value of attribute main_teacher_short_name.
-
#max_group_size ⇒ Object
readonly
Returns the value of attribute max_group_size.
Attributes inherited from Element
Instance Method Summary collapse
-
#initialize(json_info) ⇒ Classes
constructor
Initiate an instance of Classes based upon +json_info* that can be an hash or a JSON string.
-
#lectures ⇒ Object
Returns all the lectures related to this class.
-
#participants ⇒ Object
Returns all the students related to this class.
-
#resources ⇒ Object
Returns all the resources related to a certain class.
-
#to_s ⇒ Object
Small representation of the Classes object.
Methods inherited from Element
Constructor Details
#initialize(json_info) ⇒ Classes
Initiate an instance of Classes based upon +json_info* that can be an hash or a JSON string.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 22 def initialize(json_info) json_data = check_json_info json_info super(json_data[ModelUtils::ID], json_data[ModelUtils::CLASS_NAME], json_data[ModelUtils::LINKS], @@type_of_links) @full_name = json_data[ModelUtils::FULL_NAME] @course_unit_short_name = json_data[ModelUtils::COURSE_UNIT_SHORT_NAME] @main_teacher_short_name = json_data[ModelUtils::MAIN_TEACHER_SHORT_NAME] @course_unit_id = json_data[ModelUtils::COURSE_UNIT_ID] @lective_semester_id = json_data[ModelUtils::LECTIVE_SEMESTER_ID] @main_teacher_id = json_data[ModelUtils::MAIN_TEACHER_ID] @max_group_size = json_data[ModelUtils::MAX_GROUP_SIZE] #TODO aceder ao Links do super e retirar de la´ o link respectivo teacher_self_link = json_data[ModelUtils::LINKS] teacher_self_link = teacher_self_link[ModelUtils::MAIN_TEACHER] unless teacher_self_link.nil? #TODO get the id and check if a request has been made in the past teacher_self_response = RestClient.get teacher_self_link @main_teacher = Teacher.new teacher_self_response end end |
Instance Attribute Details
#course_unit_id ⇒ Object (readonly)
Returns the value of attribute course_unit_id.
17 18 19 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 17 def course_unit_id @course_unit_id end |
#course_unit_short_name ⇒ Object (readonly)
Returns the value of attribute course_unit_short_name.
16 17 18 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 16 def course_unit_short_name @course_unit_short_name end |
#full_name ⇒ Object (readonly)
Returns the value of attribute full_name.
16 17 18 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 16 def full_name @full_name end |
#lective_semester_id ⇒ Object (readonly)
Returns the value of attribute lective_semester_id.
17 18 19 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 17 def lective_semester_id @lective_semester_id end |
#main_teacher ⇒ Object (readonly)
Returns the value of attribute main_teacher.
16 17 18 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 16 def main_teacher @main_teacher end |
#main_teacher_id ⇒ Object (readonly)
Returns the value of attribute main_teacher_id.
17 18 19 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 17 def main_teacher_id @main_teacher_id end |
#main_teacher_short_name ⇒ Object (readonly)
Returns the value of attribute main_teacher_short_name.
16 17 18 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 16 def main_teacher_short_name @main_teacher_short_name end |
#max_group_size ⇒ Object (readonly)
Returns the value of attribute max_group_size.
17 18 19 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 17 def max_group_size @max_group_size end |
Instance Method Details
#lectures ⇒ Object
Returns all the lectures related to this class.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 72 def lectures response_all_lectures = RestClient.get @links.lectures all_lectures = JSON.parse response_all_lectures temp = [] all_lectures['classLectures'].each do |lecture| temp.push(Lecture.new(lecture)) end #Parallel.each(all_lectures['classLectures'], :in_processes => 1){ # |lecture| temp.push(Lecture.new(lecture)) #} temp end |
#participants ⇒ Object
Returns all the students related to this class.
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 57 def participants response_all_participants = RestClient.get @links.participants all_participants = JSON.parse response_all_participants temp = [] all_participants['students'].each do |participant| temp.push(Student.new(participant)) end #temp = Parallel.each(all_participants['students'], :in_processes => 1){ # |participant| temp.push(Student.new(participant)) #} temp end |
#resources ⇒ Object
Returns all the resources related to a certain class.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 89 def resources response_all_resources = RestClient.get @links.resources all_resources = JSON.parse response_all_resources temp = Array.new all_resources['classResources'].each do |resource| temp.push(Resource.new(resource)) end #Parallel.each(all_resources['classResources'], :in_processes => 1){ # |resource| temp << Resource.new(resource) #} temp end |
#to_s ⇒ Object
Small representation of the Classes object
51 52 53 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 51 def to_s "#{@id} - #{@full_name} - #{@main_teacher_short_name}" end |