Class: Aufgaben::Color

Inherits:
Object
  • Object
show all
Defined in:
lib/aufgaben/color.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Color

Returns a new instance of Color.



7
8
9
# File 'lib/aufgaben/color.rb', line 7

def initialize(text)
  @text = text
end

Class Method Details

.enabled?Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/aufgaben/color.rb', line 3

def self.enabled?
  $stdout.tty?
end

Instance Method Details

#greenObject



11
12
13
14
15
16
17
# File 'lib/aufgaben/color.rb', line 11

def green
  if self.class.enabled?
    "\e[32m#{@text}\e[0m"
  else
    @text
  end
end