Sha256: 899216e8d0a0ac576dc9761e3cf17bb91c0a7bedc7dae9cf1d8c43e01360dde6
Contents?: true
Size: 1.48 KB
Versions: 2
Compression:
Stored size: 1.48 KB
Contents
module Pomo class Task #-- # Mixins #++ include Growl ## # Task name. attr_accessor :name ## # Length in minutes. attr_accessor :length ## # Verbose task description. attr_accessor :description ## # Task completion bool. attr_accessor :complete ## # Initialize with _name_ and _options_. def initialize name = nil, options = {} @name = name or raise '<task> required' @description = options.delete :description @length = options.fetch :length, 25 @complete = false end ## # Quoted task name. def to_s name.inspect end ## # Check if the task has been completed. def complete? complete end ## # Start timing the task. def start complete_message = "time is up! hope you are finished #{self}" format_message = "(:progress_bar) :remaining minutes remaining" progress (0..length).to_a.reverse, :format => format_message, :tokens => { :remaining => length }, :complete_message => complete_message do |remaining| if remaining == length / 2 notify_info "#{remaining} minutes remaining, half way there!" elsif remaining == 5 notify_info "5 minutes remaining" end sleep 60 { :remaining => remaining } end @complete = true notify_warning complete_message end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pomo-1.0.1 | lib/pomo/task.rb |
pomo-1.0.0 | lib/pomo/task.rb |