Class: RBS::CLI::ColoredIO

Inherits:
Object
  • Object
show all
Defined in:
lib/rbs/cli/colored_io.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stdout:) ⇒ ColoredIO

Returns a new instance of ColoredIO.



8
9
10
# File 'lib/rbs/cli/colored_io.rb', line 8

def initialize(stdout:)
  @stdout = stdout
end

Instance Attribute Details

#stdoutObject (readonly)

Returns the value of attribute stdout.



6
7
8
# File 'lib/rbs/cli/colored_io.rb', line 6

def stdout
  @stdout
end

Instance Method Details

#putsObject



28
29
30
# File 'lib/rbs/cli/colored_io.rb', line 28

def puts(...)
  stdout.puts(...)
end

#puts_green(string) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/rbs/cli/colored_io.rb', line 20

def puts_green(string)
  if can_display_colors?
    puts "\e[32m#{string}\e[m"
  else
    puts string
  end
end

#puts_red(string) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/rbs/cli/colored_io.rb', line 12

def puts_red(string)
  if can_display_colors?
    puts "\e[31m#{string}\e[m"
  else
    puts string
  end
end