Class: Manabu::Courses
- Inherits:
-
Object
- Object
- Manabu::Courses
- Defined in:
- lib/manabu/courses.rb
Instance Method Summary collapse
- #index ⇒ Object
-
#initialize(client) ⇒ Courses
constructor
A new instance of Courses.
- #register(course) ⇒ Object
- #register_course_by_hash(course) ⇒ Object
- #register_course_by_object(course) ⇒ Object
Constructor Details
#initialize(client) ⇒ Courses
Returns a new instance of Courses.
5 6 7 |
# File 'lib/manabu/courses.rb', line 5 def initialize(client) @client = client end |
Instance Method Details
#index ⇒ Object
9 10 11 12 |
# File 'lib/manabu/courses.rb', line 9 def index # TODO format object @client.get('courses') end |
#register(course) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/manabu/courses.rb', line 14 def register(course) case course when Manabu::Course return register_course_by_object(course) when Hash return register_course_by_hash(course) end end |
#register_course_by_hash(course) ⇒ Object
29 30 31 32 33 |
# File 'lib/manabu/courses.rb', line 29 def register_course_by_hash(course) res = @client.post('courses', course) # TODO: handle errors Manabu::Course.new(@client, res) end |
#register_course_by_object(course) ⇒ Object
23 24 25 26 27 |
# File 'lib/manabu/courses.rb', line 23 def register_course_by_object(course) res = @client.post('courses', course.to_hash) # TODO: handle errors course.fill(res) end |