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.



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

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

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

Instance Method Details

#mastered?Boolean

Returns:

  • (Boolean)


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

def mastered?
  units.reduce(true) { |mastered, unit| mastered &&= unit.mastered? }
end

#started?Boolean

Returns:

  • (Boolean)


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

def started?
  units.reduce(false) { |started, unit| started ||= unit.mastered? }
end

#unitsObject



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

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