Class: Manabu::Course
Defined Under Namespace
Classes: Enrollment
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#enrollments_count ⇒ Object
readonly
Returns the value of attribute enrollments_count.
-
#facility_id ⇒ Object
readonly
Returns the value of attribute facility_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#notes_count ⇒ Object
readonly
Returns the value of attribute notes_count.
-
#students_count ⇒ Object
readonly
Returns the value of attribute students_count.
-
#syllbaus_id ⇒ Object
readonly
Returns the value of attribute syllbaus_id.
Instance Method Summary collapse
- #add_student(student, args = {}) ⇒ Object
- #enrollments ⇒ Object
- #fill(**info) ⇒ Object
-
#initialize(client, **info) ⇒ Course
constructor
A new instance of Course.
- #students ⇒ Object
Methods inherited from Resource
Constructor Details
#initialize(client, **info) ⇒ Course
Returns a new instance of Course.
43 44 45 46 47 |
# File 'lib/manabu/course.rb', line 43 def initialize(client, **info) super @students = [] @enrollments = [] end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
40 41 42 |
# File 'lib/manabu/course.rb', line 40 def code @code end |
#enrollments_count ⇒ Object (readonly)
Returns the value of attribute enrollments_count.
40 41 42 |
# File 'lib/manabu/course.rb', line 40 def enrollments_count @enrollments_count end |
#facility_id ⇒ Object (readonly)
Returns the value of attribute facility_id.
40 41 42 |
# File 'lib/manabu/course.rb', line 40 def facility_id @facility_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
40 41 42 |
# File 'lib/manabu/course.rb', line 40 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
40 41 42 |
# File 'lib/manabu/course.rb', line 40 def name @name end |
#notes_count ⇒ Object (readonly)
Returns the value of attribute notes_count.
40 41 42 |
# File 'lib/manabu/course.rb', line 40 def notes_count @notes_count end |
#students_count ⇒ Object (readonly)
Returns the value of attribute students_count.
40 41 42 |
# File 'lib/manabu/course.rb', line 40 def students_count @students_count end |
#syllbaus_id ⇒ Object (readonly)
Returns the value of attribute syllbaus_id.
40 41 42 |
# File 'lib/manabu/course.rb', line 40 def syllbaus_id @syllbaus_id end |
Instance Method Details
#add_student(student, args = {}) ⇒ Object
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/manabu/course.rb', line 77 def add_student(student, args = {}) response = @client.post("courses/#{id}/enrollments", student_id: student.id, seat_number: args[:seat_number] ) Enrollment.new(@client, response).tap do |enrollment| @enrollments << enrollment end end |
#enrollments ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/manabu/course.rb', line 69 def enrollments if @enrollments.any? @enrollments else @enrollments = _fetch_enrollments end end |
#fill(**info) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/manabu/course.rb', line 49 def fill(**info) @id = info.fetch(:id, @id) @name = info.fetch(:name, @name) @code = info.fetch(:code, @code) @notes_count = info.fetch(:notes_count, @notes_count) @students_count = info.fetch(:students_count, @students_count) @enrollments_count = info.fetch(:enrollments_count, @enrollments_count) @facility_id = info.fetch(:facility_id, @facility_id) @syllabus_id = info.fetch(:syllabus_id, @syllabus_id) self end |
#students ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/manabu/course.rb', line 61 def students if @students.any? @students else @students = _fetch_students end end |