Class: TheFox::Timr::Status

Inherits:
Object
  • Object
show all
Includes:
Term::ANSIColor
Defined in:
lib/timr/status.rb

Overview

Used as [Task](TheFox::Timr::Model::Task) and [Track](TheFox::Timr::Model::Track) Status.

  • ‘R` running

  • ‘S` stopped

  • ‘P` paused. It’s actually stopped but with an additional flag.

  • ‘-` (dash) not started

  • ‘U` unknown

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(short_status) ⇒ Status

Returns a new instance of Status.



24
25
26
27
28
29
# File 'lib/timr/status.rb', line 24

def initialize(short_status)
  @short_status = short_status
  
  @long_status = nil
  set_long_status
end

Instance Attribute Details

#long_statusObject (readonly)

Resolved by ‘short_status`. See `set_long_status` method.



22
23
24
# File 'lib/timr/status.rb', line 22

def long_status
  @long_status
end

#short_statusObject (readonly)

Source Data



19
20
21
# File 'lib/timr/status.rb', line 19

def short_status
  @short_status
end

Instance Method Details

#colorizedObject

Use ‘term/ansicolor` to colorize the Long Status.



32
33
34
35
36
37
38
39
40
41
# File 'lib/timr/status.rb', line 32

def colorized
  case @short_status
  when ?R
    green(@long_status)
  when ?S
    red(@long_status)
  else
    @long_status
  end
end

#to_sObject

To String



44
45
46
# File 'lib/timr/status.rb', line 44

def to_s
  long_status
end