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 ' 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}" progress (0..length).to_a.reverse, :format => "(:progress_bar) :remaining minutes remaining", :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