class KBSecret::Record::Todo

Represents a record containing a 'to do' item and its status.

Apart from the text of the item itself, each record contains three relevant fields: the item's status, a start time, and a stop time.

The status is one of `“started”`, `“suspended”`, or `“complete”`, each of which should be self-explanatory.

The start time is the date and time at which the item was started via {#start!}.

The stop time is the date and time at which the item was either last suspended via {#suspend!} or finished via {#complete!}.

Public Instance Methods

complete!() click to toggle source

Complete the to do item. @return [void] @note Does nothing if the item is already completed.

# File lib/kbsecret/record/todo.rb, line 82
def complete!
  return if completed?
  self.status = "complete"
  self.stop   = Time.now.to_s
end
completed?() click to toggle source

@return [Boolean] whether or not the item is marked as completed

# File lib/kbsecret/record/todo.rb, line 56
def completed?
  !(started? || suspended?)
end
populate_internal_fields() click to toggle source

@return [void] @see Abstract#populate_internal_fields

# File lib/kbsecret/record/todo.rb, line 37
def populate_internal_fields
  defer_sync implicit: false do
    self.status = "suspended"
    self.start = nil
    self.stop = nil
  end
end
start!() click to toggle source

Start the to do item. @return [void] @note Does nothing if the item is already started.

# File lib/kbsecret/record/todo.rb, line 63
def start!
  return if started?

  self.status = "started"
  self.start  = Time.now.to_s
end
started?() click to toggle source

@return [Boolean] whether or not the item is marked as started

# File lib/kbsecret/record/todo.rb, line 46
def started?
  status == "started"
end
suspend!() click to toggle source

Suspend the to do item. @return [void] @note Does nothing if the item is already suspended.

# File lib/kbsecret/record/todo.rb, line 73
def suspend!
  return if suspended?
  self.status = "suspended"
  self.stop   = Time.now.to_s
end
suspended?() click to toggle source

@return [Boolean] whether or not the item is marked as suspended

# File lib/kbsecret/record/todo.rb, line 51
def suspended?
  status == "suspended"
end