class Versed::Task

Constants

ACTIVE_STYLE
DANGER_STYLE
SUCCESS_STYLE
WARN_STYLE

Attributes

category_id[RW]
date[RW]
time_scheduled[RW]
time_spent[RW]

Public Class Methods

new(category_id, date) click to toggle source
# File lib/versed/task.rb, line 5
def initialize(category_id, date)
  @category_id = category_id
  @date = date
end

Public Instance Methods

time_scheduled?() click to toggle source
# File lib/versed/task.rb, line 30
def time_scheduled?
  self.time_scheduled && self.time_scheduled > 0
end
time_spent?() click to toggle source
# File lib/versed/task.rb, line 26
def time_spent?
  self.time_spent && self.time_spent > 0
end
to_hash() click to toggle source
# File lib/versed/task.rb, line 10
def to_hash
  {
    "time_spent" => self.time_spent.to_s,
    "time_scheduled" => self.time_scheduled.to_s,
    "style" => style
  }
end

Private Instance Methods

style() click to toggle source
# File lib/versed/task.rb, line 41
def style
  return ACTIVE_STYLE if self.date >= Date.today

  return unless self.time_scheduled && self.time_scheduled > 0

  if !self.time_spent || self.time_spent <= 0
    return DANGER_STYLE
  elsif self.time_spent < self.time_scheduled
    return WARN_STYLE
  else
    return SUCCESS_STYLE
  end
end