Class: RBS::CLI::ColoredIO
- Inherits:
-
Object
- Object
- RBS::CLI::ColoredIO
- Defined in:
- lib/rbs/cli/colored_io.rb
Instance Attribute Summary collapse
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
-
#initialize(stdout:) ⇒ ColoredIO
constructor
A new instance of ColoredIO.
- #puts ⇒ Object
- #puts_green(string) ⇒ Object
- #puts_red(string) ⇒ Object
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
#stdout ⇒ Object (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
#puts ⇒ Object
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 |