Class: Daigaku::Chapter

Inherits:
Object
  • Object
show all
Defined in:
lib/daigaku/chapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Chapter

Returns a new instance of Chapter.



5
6
7
8
# File 'lib/daigaku/chapter.rb', line 5

def initialize(path)
  @path  = path
  @title = File.basename(path).gsub(/\_+/, ' ')
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/daigaku/chapter.rb', line 3

def path
  @path
end

#titleObject (readonly)

Returns the value of attribute title.



3
4
5
# File 'lib/daigaku/chapter.rb', line 3

def title
  @title
end

Instance Method Details

#mastered?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/daigaku/chapter.rb', line 18

def mastered?
  units.all?(&:mastered?)
end

#started?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/daigaku/chapter.rb', line 14

def started?
  units.any?(&:mastered?)
end

#unitsObject



10
11
12
# File 'lib/daigaku/chapter.rb', line 10

def units
  @units ||= Loading::Units.load(@path)
end