class TimeLogRobot::Toggl::Entry
Attributes
duration[RW]
raw_entry[RW]
Public Class Methods
new(raw_entry)
click to toggle source
# File lib/time_log_robot/toggl/entry.rb, line 6 def initialize(raw_entry) @raw_entry = raw_entry end
Public Instance Methods
comment()
click to toggle source
# File lib/time_log_robot/toggl/entry.rb, line 14 def comment matches = raw_entry['description'].match(/(\{(?<comment>[^\}]*)\})/) return matches['comment'] unless matches.nil? || !matches.strip.empty? description end
description()
click to toggle source
# File lib/time_log_robot/toggl/entry.rb, line 10 def description raw_entry['description'] end
duration_in_seconds()
click to toggle source
# File lib/time_log_robot/toggl/entry.rb, line 24 def duration_in_seconds # Toggl sends times in milliseconds @duration_in_seconds ||= raw_entry['dur']/1000 end
human_readable_duration()
click to toggle source
@TODO This probably belongs on the reporter class?
# File lib/time_log_robot/toggl/entry.rb, line 30 def human_readable_duration total_minutes = duration_in_seconds/60 hours = total_minutes/60 remaining_minutes = total_minutes - hours * 60 "#{hours}h #{remaining_minutes}m" end
id()
click to toggle source
# File lib/time_log_robot/toggl/entry.rb, line 37 def id raw_entry['id'] end
project_name()
click to toggle source
# File lib/time_log_robot/toggl/entry.rb, line 45 def project_name raw_entry['project'] || '' end
should_tag?()
click to toggle source
# File lib/time_log_robot/toggl/entry.rb, line 49 def should_tag? true end
start()
click to toggle source
# File lib/time_log_robot/toggl/entry.rb, line 20 def start DateTime.strptime(raw_entry['start'], "%FT%T%:z").strftime("%FT%T.%L%z") end