Class: Daigaku::Chapter
- Inherits:
-
Object
- Object
- Daigaku::Chapter
- Defined in:
- lib/daigaku/chapter.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(path) ⇒ Chapter
constructor
A new instance of Chapter.
- #mastered? ⇒ Boolean
- #started? ⇒ Boolean
- #units ⇒ Object
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
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/daigaku/chapter.rb', line 4 def path @path end |
#title ⇒ Object (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
19 20 21 |
# File 'lib/daigaku/chapter.rb', line 19 def mastered? units.reduce(true) { |mastered, unit| mastered &&= unit.mastered? } end |
#started? ⇒ Boolean
15 16 17 |
# File 'lib/daigaku/chapter.rb', line 15 def started? units.reduce(false) { |started, unit| started ||= unit.mastered? } end |