Class: TimeTracker::Month
- Inherits:
-
Object
- Object
- TimeTracker::Month
- Defined in:
- lib/time_tracker.rb
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#fixed_monthly_working_time ⇒ Object
offset means +/- hours within this month global_offset within the whole year as a sum.
-
#global_offset ⇒ Object
offset means +/- hours within this month global_offset within the whole year as a sum.
-
#monthly_working_time ⇒ Object
readonly
Returns the value of attribute monthly_working_time.
-
#offset ⇒ Object
offset means +/- hours within this month global_offset within the whole year as a sum.
Instance Method Summary collapse
- #add_event(event) ⇒ Object
- #calulate_working_time ⇒ Object
-
#initialize ⇒ Month
constructor
A new instance of Month.
- #sort_entries! ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Month
Returns a new instance of Month.
20 21 22 23 |
# File 'lib/time_tracker.rb', line 20 def initialize @entries = Array.new #@fixed_monthly_working_time end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
15 16 17 |
# File 'lib/time_tracker.rb', line 15 def entries @entries end |
#fixed_monthly_working_time ⇒ Object
offset means +/- hours within this month global_offset within the whole year as a sum
18 19 20 |
# File 'lib/time_tracker.rb', line 18 def fixed_monthly_working_time @fixed_monthly_working_time end |
#global_offset ⇒ Object
offset means +/- hours within this month global_offset within the whole year as a sum
18 19 20 |
# File 'lib/time_tracker.rb', line 18 def global_offset @global_offset end |
#monthly_working_time ⇒ Object (readonly)
Returns the value of attribute monthly_working_time.
15 16 17 |
# File 'lib/time_tracker.rb', line 15 def monthly_working_time @monthly_working_time end |
#offset ⇒ Object
offset means +/- hours within this month global_offset within the whole year as a sum
18 19 20 |
# File 'lib/time_tracker.rb', line 18 def offset @offset end |
Instance Method Details
#add_event(event) ⇒ Object
25 26 27 |
# File 'lib/time_tracker.rb', line 25 def add_event event @entries.push(Entry.new(event)) end |
#calulate_working_time ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/time_tracker.rb', line 33 def calulate_working_time @monthly_working_time = 0 @entries.each do |entry| @monthly_working_time += entry.duration end @offset = @monthly_working_time - @fixed_monthly_working_time @global_offset += @offset end |
#sort_entries! ⇒ Object
29 30 31 |
# File 'lib/time_tracker.rb', line 29 def sort_entries! @entries.sort! { |a,b| a.start_time <=> b.start_time } end |
#to_s ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/time_tracker.rb', line 42 def to_s entries = "Entries: \n" @entries.each do |entry| entries += "#{entry} \n" end entries end |