Class: Lessonly::Lesson
- Inherits:
-
Object
- Object
- Lessonly::Lesson
- Includes:
- HTTParty
- Defined in:
- lib/lessonly/lesson.rb
Instance Attribute Summary collapse
-
#assignees_count ⇒ Object
readonly
Returns the value of attribute assignees_count.
-
#completed_count ⇒ Object
readonly
Returns the value of attribute completed_count.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(response) ⇒ Lesson
constructor
A new instance of Lesson.
Constructor Details
#initialize(response) ⇒ Lesson
Returns a new instance of Lesson.
19 20 21 22 23 24 |
# File 'lib/lessonly/lesson.rb', line 19 def initialize(response) @id = response["id"] @title = response["title"] @assignees_count = response["assignees_count"] @completed_count = response["completed_count"] end |
Instance Attribute Details
#assignees_count ⇒ Object (readonly)
Returns the value of attribute assignees_count.
17 18 19 |
# File 'lib/lessonly/lesson.rb', line 17 def assignees_count @assignees_count end |
#completed_count ⇒ Object (readonly)
Returns the value of attribute completed_count.
17 18 19 |
# File 'lib/lessonly/lesson.rb', line 17 def completed_count @completed_count end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
17 18 19 |
# File 'lib/lessonly/lesson.rb', line 17 def id @id end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
17 18 19 |
# File 'lib/lessonly/lesson.rb', line 17 def title @title end |
Class Method Details
.all ⇒ Object
12 13 14 15 |
# File 'lib/lessonly/lesson.rb', line 12 def self.all lessons_data = get("/lessons").parsed_response lessons_data["lessons"].map { |data| new(data) } end |
.find(id) ⇒ Object
7 8 9 10 |
# File 'lib/lessonly/lesson.rb', line 7 def self.find(id) lesson_data = get("/lessons/#{id}").parsed_response new(lesson_data) end |