Class: Lessonly::Lesson

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/lessonly/lesson.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_countObject (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_countObject (readonly)

Returns the value of attribute completed_count.



17
18
19
# File 'lib/lessonly/lesson.rb', line 17

def completed_count
  @completed_count
end

#idObject (readonly)

Returns the value of attribute id.



17
18
19
# File 'lib/lessonly/lesson.rb', line 17

def id
  @id
end

#titleObject (readonly)

Returns the value of attribute title.



17
18
19
# File 'lib/lessonly/lesson.rb', line 17

def title
  @title
end

Class Method Details

.allObject



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