Class: PnoteClient::Documents::Pnote

Inherits:
Object
  • Object
show all
Defined in:
lib/pnote_client/documents/pnote.rb,
lib/pnote_client/documents/pnote/image.rb,
lib/pnote_client/documents/pnote/chapter.rb,
lib/pnote_client/documents/pnote/concept.rb,
lib/pnote_client/documents/pnote/problem.rb,
lib/pnote_client/documents/pnote/sub_chapter.rb,
lib/pnote_client/documents/pnote/teacher_comment.rb

Defined Under Namespace

Classes: Chapter, Concept, Image, Problem, SubChapter, TeacherComment

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePnote

Returns a new instance of Pnote.



6
7
8
9
# File 'lib/pnote_client/documents/pnote.rb', line 6

def initialize()
  @chapters = []
  @images = []
end

Instance Attribute Details

#chaptersObject (readonly)

Returns the value of attribute chapters.



4
5
6
# File 'lib/pnote_client/documents/pnote.rb', line 4

def chapters
  @chapters
end

#imagesObject (readonly)

Returns the value of attribute images.



4
5
6
# File 'lib/pnote_client/documents/pnote.rb', line 4

def images
  @images
end

Instance Method Details

#add_chapter(new_chapter) ⇒ Object



11
12
13
# File 'lib/pnote_client/documents/pnote.rb', line 11

def add_chapter(new_chapter)
  @chapters << new_chapter
end

#add_image(new_image) ⇒ Object



15
16
17
# File 'lib/pnote_client/documents/pnote.rb', line 15

def add_image(new_image)
  @images << new_image
end

#exercise_countObject



19
20
21
22
23
24
25
# File 'lib/pnote_client/documents/pnote.rb', line 19

def exercise_count
  return @chapters.sum do |chapter|
    chapter.sub_chapters.sum do |sub_chapter|
      sub_chapter.exercises.count
    end
  end
end

#practice_countObject



27
28
29
30
31
32
33
# File 'lib/pnote_client/documents/pnote.rb', line 27

def practice_count
  return @chapters.sum do |chapter|
    chapter.sub_chapters.sum do |sub_chapter|
      sub_chapter.practices.count
    end
  end
end