Class: LearningDiary
- Inherits:
-
Object
- Object
- LearningDiary
- Includes:
- Enumerable
- Defined in:
- lib/docfolio/learning_diary.rb
Overview
collection class for paragraphs synonym ‘Topic’ ‘Learning Diary’
Instance Attribute Summary collapse
-
#impact_credits ⇒ Object
readonly
The credit arrays are arrays of elements of type [start_time, end_time, duration], one for each tag in all the paragraphs that earns credit.
-
#paragraphs ⇒ Object
readonly
Paragraphs is an array representing the parsed DSL from one file.
-
#standard_credits ⇒ Object
readonly
The credit arrays are arrays of elements of type [start_time, end_time, duration], one for each tag in all the paragraphs that earns credit.
Instance Method Summary collapse
-
#[](index) ⇒ Object
Implements [] by indexing the @paragraphs instance variable.
-
#credits_total ⇒ Integer
The sum of the impact and standard credits in minutes.
-
#each(&block) ⇒ Object
Implements Enuemerable module by iterating through each paragraph in the learning diary.
-
#impact_credits_total ⇒ Integer
The sum of the impact credits in minutes.
-
#initialize(file) ⇒ LearningDiary
constructor
A new instance of LearningDiary.
- #significant_event? ⇒ Boolean
-
#standard_credits_total ⇒ Integer
The sum of the standard credits in minutes.
Constructor Details
#initialize(file) ⇒ LearningDiary
Returns a new instance of LearningDiary.
18 19 20 21 22 |
# File 'lib/docfolio/learning_diary.rb', line 18 def initialize(file) initialize_vars parse(file) calculate_credits end |
Instance Attribute Details
#impact_credits ⇒ Object (readonly)
The credit arrays are arrays of elements of type [start_time, end_time, duration], one for each tag in all the paragraphs that earns credit
15 16 17 |
# File 'lib/docfolio/learning_diary.rb', line 15 def impact_credits @impact_credits end |
#paragraphs ⇒ Object (readonly)
Paragraphs is an array representing the parsed DSL from one file
10 11 12 |
# File 'lib/docfolio/learning_diary.rb', line 10 def paragraphs @paragraphs end |
#standard_credits ⇒ Object (readonly)
The credit arrays are arrays of elements of type [start_time, end_time, duration], one for each tag in all the paragraphs that earns credit
15 16 17 |
# File 'lib/docfolio/learning_diary.rb', line 15 def standard_credits @standard_credits end |
Instance Method Details
#[](index) ⇒ Object
Implements [] by indexing the @paragraphs instance variable
31 32 33 |
# File 'lib/docfolio/learning_diary.rb', line 31 def [](index) @paragraphs[index] end |
#credits_total ⇒ Integer
Returns The sum of the impact and standard credits in minutes.
46 47 48 |
# File 'lib/docfolio/learning_diary.rb', line 46 def credits_total impact_credits_total + standard_credits_total end |
#each(&block) ⇒ Object
Implements Enuemerable module by iterating through each paragraph in the learning diary
26 27 28 |
# File 'lib/docfolio/learning_diary.rb', line 26 def each(&block) @paragraphs.each { |p| block.call(p) } end |
#impact_credits_total ⇒ Integer
Returns The sum of the impact credits in minutes.
41 42 43 |
# File 'lib/docfolio/learning_diary.rb', line 41 def impact_credits_total impact_credits.reduce(0) { |a, e| a + e[2] } end |
#significant_event? ⇒ Boolean
50 51 52 53 |
# File 'lib/docfolio/learning_diary.rb', line 50 def significant_event? paragraphs.each { |p| return true if p.significant_event? } false end |
#standard_credits_total ⇒ Integer
Returns The sum of the standard credits in minutes.
36 37 38 |
# File 'lib/docfolio/learning_diary.rb', line 36 def standard_credits_total standard_credits.reduce(0) { |a, e| a + e[2] } end |