Class: Manabu::Student
Defined Under Namespace
Classes: GuardianNotAdded
Instance Attribute Summary collapse
-
#birth_date ⇒ Object
Returns the value of attribute birth_date.
-
#gender ⇒ Object
Returns the value of attribute gender.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#name_reading ⇒ Object
Returns the value of attribute name_reading.
-
#surname ⇒ Object
Returns the value of attribute surname.
-
#surname_reading ⇒ Object
Returns the value of attribute surname_reading.
Instance Method Summary collapse
- #add_guardian(guardian) ⇒ Object
- #courses ⇒ Object
- #fill(**info) ⇒ Object
- #guardians ⇒ Object
- #set(**info) ⇒ Object
Methods inherited from Resource
Constructor Details
This class inherits a constructor from Manabu::Resource
Instance Attribute Details
#birth_date ⇒ Object
Returns the value of attribute birth_date.
7 8 9 |
# File 'lib/manabu/student.rb', line 7 def birth_date @birth_date end |
#gender ⇒ Object
Returns the value of attribute gender.
7 8 9 |
# File 'lib/manabu/student.rb', line 7 def gender @gender end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/manabu/student.rb', line 7 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/manabu/student.rb', line 7 def name @name end |
#name_reading ⇒ Object
Returns the value of attribute name_reading.
7 8 9 |
# File 'lib/manabu/student.rb', line 7 def name_reading @name_reading end |
#surname ⇒ Object
Returns the value of attribute surname.
7 8 9 |
# File 'lib/manabu/student.rb', line 7 def surname @surname end |
#surname_reading ⇒ Object
Returns the value of attribute surname_reading.
7 8 9 |
# File 'lib/manabu/student.rb', line 7 def surname_reading @surname_reading end |
Instance Method Details
#add_guardian(guardian) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/manabu/student.rb', line 27 def add_guardian(guardian) # NOTE: detect when guardian is already added to student response = @client.post("students/#{id}/student_guardians", guardian_id: guardian.id) self rescue StandardError raise GuardianNotAdded, 'Guardian is not added to student' end |
#courses ⇒ Object
42 43 44 45 46 47 |
# File 'lib/manabu/student.rb', line 42 def courses response = @client.get("students/#{id}/courses") response[:courses].map do |course| Manabu::Course.new(@client, course) end end |
#fill(**info) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/manabu/student.rb', line 10 def fill(**info) @id = info.fetch(:id, @id) @surname = info.fetch(:surname, @surname) @name = info.fetch(:name, @name) @name_reading = info.fetch(:name_reading, @name_reading) @surname_reading = info.fetch(:surname_reading, @surname_reading) @birth_date = info.fetch(:birth_date, @birth_date) @gender = info.fetch(:gender, @gender) self end |
#guardians ⇒ Object
35 36 37 38 39 40 |
# File 'lib/manabu/student.rb', line 35 def guardians response = @client.get("students/#{id}/guardians") response[:guardians].map do |guardian| Manabu::Guardian.new(@client, guardian) end end |
#set(**info) ⇒ Object
22 23 24 25 |
# File 'lib/manabu/student.rb', line 22 def set(**info) response = @client.patch("students/#{@id}", info) fill(response) end |