Module: Insta::ANSI

Included in:
CLI
Defined in:
lib/insta/ansi.rb,
sig/insta/ansi.rbs

Instance Method Summary collapse

Instance Method Details

#bold(text) ⇒ String

: (String) -> String

Parameters:

  • (String)

Returns:

  • (String)


13
# File 'lib/insta/ansi.rb', line 13

def bold(text) = $stdout.tty? ? "\e[1m#{text}\e[0m" : text

#color?Boolean

: () -> bool

Returns:

  • (Boolean)


8
9
10
# File 'lib/insta/ansi.rb', line 8

def color?
  !ENV.key?("NO_COLOR") && $stdout.tty?
end

#cyan(text) ⇒ String

: (String) -> String

Parameters:

  • (String)

Returns:

  • (String)


28
# File 'lib/insta/ansi.rb', line 28

def cyan(text) = color? ? "\e[36m#{text}\e[0m" : text

#dim(text) ⇒ String

: (String) -> String

Parameters:

  • (String)

Returns:

  • (String)


16
# File 'lib/insta/ansi.rb', line 16

def dim(text) = $stdout.tty? ? "\e[2m#{text}\e[0m" : text

#green(text) ⇒ String

: (String) -> String

Parameters:

  • (String)

Returns:

  • (String)


22
# File 'lib/insta/ansi.rb', line 22

def green(text) = color? ? "\e[32m#{text}\e[0m" : text

#red(text) ⇒ String

: (String) -> String

Parameters:

  • (String)

Returns:

  • (String)


19
# File 'lib/insta/ansi.rb', line 19

def red(text) = color? ? "\e[31m#{text}\e[0m" : text

#yellow(text) ⇒ String

: (String) -> String

Parameters:

  • (String)

Returns:

  • (String)


25
# File 'lib/insta/ansi.rb', line 25

def yellow(text) = color? ? "\e[33m#{text}\e[0m" : text