Class: Versed::Category
- Inherits:
-
Object
- Object
- Versed::Category
- Defined in:
- lib/versed/category.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#tasks ⇒ Object
readonly
Returns the value of attribute tasks.
Instance Method Summary collapse
- #incomplete? ⇒ Boolean
-
#initialize(id, date_range) ⇒ Category
constructor
A new instance of Category.
- #percent_incomplete ⇒ Object
- #total_min_incomplete ⇒ Object
- #total_min_logged ⇒ Object
- #total_min_scheduled ⇒ Object
Constructor Details
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/versed/category.rb', line 5 def id @id end |
#tasks ⇒ Object (readonly)
Returns the value of attribute tasks.
5 6 7 |
# File 'lib/versed/category.rb', line 5 def tasks @tasks end |
Instance Method Details
#incomplete? ⇒ Boolean
13 14 15 |
# File 'lib/versed/category.rb', line 13 def incomplete? total_min_incomplete > 0 end |
#percent_incomplete ⇒ Object
40 41 42 |
# File 'lib/versed/category.rb', line 40 def percent_incomplete ((total_min_incomplete / total_min_scheduled.to_f) * 100).round(1) end |
#total_min_incomplete ⇒ Object
35 36 37 38 |
# File 'lib/versed/category.rb', line 35 def total_min_incomplete incomplete = total_min_scheduled - total_min_logged incomplete >= 0 ? incomplete : 0 end |
#total_min_logged ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/versed/category.rb', line 26 def total_min_logged logged = 0 @tasks.each do |task| next unless task.time_spent logged += task.time_spent end logged end |
#total_min_scheduled ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/versed/category.rb', line 17 def total_min_scheduled scheduled = 0 @tasks.each do |task| next unless task.time_scheduled scheduled += task.time_scheduled end scheduled end |