Class: Pomodoro::Formats::Today::Task

Inherits:
Object
  • Object
show all
Includes:
DynamicAdditions, TaskStatuses
Defined in:
lib/pomodoro/formats/today/task.rb

Instance Attribute Summary collapse

Attributes included from DynamicAdditions

#command

Instance Method Summary collapse

Methods included from TaskStatuses

#complete!, #completed?, #delete!, #deleted?, #ended?, #finish_for_the_day!, #in_progress?, #postpone!, #postponed?, #progress_made_but_not_finished?, #skipped?, #start!, #unstarted?

Constructor Details

#initialize(status:, body:, start_time: nil, end_time: nil, fixed_start_time: nil, duration: nil, tags: [], lines: []) ⇒ Task

Returns a new instance of Task.



22
23
24
25
26
# File 'lib/pomodoro/formats/today/task.rb', line 22

def initialize(status:, body:, start_time: nil, end_time: nil, fixed_start_time: nil, duration: nil, tags: [], lines: [])
  @status, @body, @tags, @duration = status, body, tags, duration
  @start_time, @end_time, @fixed_start_time = start_time, end_time, fixed_start_time
  validate_data_integrity
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



21
22
23
# File 'lib/pomodoro/formats/today/task.rb', line 21

def body
  @body
end

#durationObject (readonly)

Returns the value of attribute duration.



21
22
23
# File 'lib/pomodoro/formats/today/task.rb', line 21

def duration
  @duration
end

#end_timeObject (readonly)

Returns the value of attribute end_time.



21
22
23
# File 'lib/pomodoro/formats/today/task.rb', line 21

def end_time
  @end_time
end

#fixed_start_timeObject (readonly)

Returns the value of attribute fixed_start_time.



21
22
23
# File 'lib/pomodoro/formats/today/task.rb', line 21

def fixed_start_time
  @fixed_start_time
end

#linesObject (readonly)

Returns the value of attribute lines.



21
22
23
# File 'lib/pomodoro/formats/today/task.rb', line 21

def lines
  @lines
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



21
22
23
# File 'lib/pomodoro/formats/today/task.rb', line 21

def start_time
  @start_time
end

#statusObject (readonly)

Returns the value of attribute status.



21
22
23
# File 'lib/pomodoro/formats/today/task.rb', line 21

def status
  @status
end

#tagsObject (readonly)

Returns the value of attribute tags.



21
22
23
# File 'lib/pomodoro/formats/today/task.rb', line 21

def tags
  @tags
end

Instance Method Details

#remaining_duration(current_time_frame) ⇒ Object



28
29
30
31
32
33
# File 'lib/pomodoro/formats/today/task.rb', line 28

def remaining_duration(current_time_frame)
  @start_time || raise("The task #{self.inspect} hasn't been started yet.")

  closing_time = @start_time + duration
  interval_end_time = current_time_frame.interval[1]
end

#to_sObject



35
36
37
# File 'lib/pomodoro/formats/today/task.rb', line 35

def to_s
  Formatter.format(self)
end