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.
Constructor Details
#initialize(json_info) ⇒ Classes
Initiate an instance of Classes based upon +json_info* that can be an hash or a JSON string.
21 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 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 21 def initialize(json_info) json_data = ModelUtils::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.
16 17 18 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 16 def course_unit_id @course_unit_id end |
#course_unit_short_name ⇒ Object (readonly)
Returns the value of attribute course_unit_short_name.
15 16 17 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 15 def course_unit_short_name @course_unit_short_name end |
#full_name ⇒ Object (readonly)
Returns the value of attribute full_name.
15 16 17 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 15 def full_name @full_name end |
#lective_semester_id ⇒ Object (readonly)
Returns the value of attribute lective_semester_id.
16 17 18 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 16 def lective_semester_id @lective_semester_id end |
#main_teacher ⇒ Object (readonly)
Returns the value of attribute main_teacher.
15 16 17 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 15 def main_teacher @main_teacher end |
#main_teacher_id ⇒ Object (readonly)
Returns the value of attribute main_teacher_id.
16 17 18 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 16 def main_teacher_id @main_teacher_id end |
#main_teacher_short_name ⇒ Object (readonly)
Returns the value of attribute main_teacher_short_name.
15 16 17 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 15 def main_teacher_short_name @main_teacher_short_name end |
#max_group_size ⇒ Object (readonly)
Returns the value of attribute max_group_size.
16 17 18 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 16 def max_group_size @max_group_size end |
Instance Method Details
#lectures ⇒ Object
Returns all the lectures related to this class.
68 69 70 71 72 73 74 75 76 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 68 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 temp end |
#participants ⇒ Object
Returns all the students related to this class.
56 57 58 59 60 61 62 63 64 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 56 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 end |
#resources ⇒ Object
Returns all the resources related to a certain class.
80 81 82 83 84 85 86 87 88 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 80 def resources response_all_resources = RestClient.get @links.resources all_resources = JSON.parse response_all_resources temp = [] all_resources['classResources'].each do |resource| temp.push Resource.new resource end temp end |
#to_s ⇒ Object
Small representation of the Classes object
50 51 52 |
# File 'lib/Appolo/Models/main_model/classes.rb', line 50 def to_s "#{@id} - #{@full_name} - #{@main_teacher_short_name}" end |