Class: Daigaku::Course
- Inherits:
-
Object
- Object
- Daigaku::Course
- Defined in:
- lib/daigaku/course.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #chapters ⇒ Object
-
#initialize(path) ⇒ Course
constructor
A new instance of Course.
- #key(key_name) ⇒ Object
- #mastered? ⇒ Boolean
- #started? ⇒ Boolean
Constructor Details
#initialize(path) ⇒ Course
Returns a new instance of Course.
6 7 8 9 10 |
# File 'lib/daigaku/course.rb', line 6 def initialize(path) @path = path @title = File.basename(path).gsub(/\_+/, ' ') = QuickStore.store.get(key(:author)) end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
4 5 6 |
# File 'lib/daigaku/course.rb', line 4 def end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
4 5 6 |
# File 'lib/daigaku/course.rb', line 4 def link @link end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/daigaku/course.rb', line 4 def path @path end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
4 5 6 |
# File 'lib/daigaku/course.rb', line 4 def title @title end |
Instance Method Details
#chapters ⇒ Object
12 13 14 |
# File 'lib/daigaku/course.rb', line 12 def chapters @chapters ||= Loading::Chapters.load(@path) end |
#key(key_name) ⇒ Object
24 25 26 |
# File 'lib/daigaku/course.rb', line 24 def key(key_name) Storeable.key(title, prefix: 'courses', suffix: key_name) end |
#mastered? ⇒ Boolean
20 21 22 |
# File 'lib/daigaku/course.rb', line 20 def mastered? chapters.reduce(true) { |mastered, chapter| mastered &&= chapter.mastered? } end |
#started? ⇒ Boolean
16 17 18 |
# File 'lib/daigaku/course.rb', line 16 def started? chapters.reduce(false) { |started, chapter| started ||= chapter.started? } end |