Created
June 25, 2009 16:44
-
-
Save jsanti/135966 to your computer and use it in GitHub Desktop.
Revisions
-
jsanti created this gist
Jun 25, 2009 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ class Status STATUS_CODES = { :queued => 0, :running => 1, :error => 2, :success => 3 } STATUS_NAMES = { :queued => "En cola de espera", :running => "En ejecución", :error => "Terminado con errores", :success => "Terminado sin errores" } cattr_accessor STATUS_CODES attr_accessor :code def initialize(code) @code = code end def to_s status_name end def status_name STATUS_NAMES[status] end def status STATUS_CODES.each do |k, v| return k if v == @code end end def is_queued?; @code == STATUS_CODES[:queued] end def is_running?; @code == STATUS_CODES[:running] end def is_error?; @code == STATUS_CODES[:error] end def is_success?; @code == STATUS_CODES[:success] end def is_finished?; is_error? || is_success? end end def estado Status.new(super) end