Sha256: 42a2f5344fb04dd1d1b06e0d427490bef47c76e0e2f7faa8ac418e0d40ed567a

Contents?: true

Size: 1.37 KB

Versions: 9

Compression:

Stored size: 1.37 KB

Contents

# encoding: utf-8

module Pastel
  # Mixin that provides ANSI codes
  module ANSI
    ATTRIBUTES = {
      clear:      0,
      reset:      0,
      bold:       1,
      dark:       2,
      dim:        2,
      italic:     3,
      underline:  4,
      underscore: 4,
      inverse:    7,
      hidden:     8,
      strikethrough: 9,

      black:   30,
      red:     31,
      green:   32,
      yellow:  33,
      blue:    34,
      magenta: 35,
      cyan:    36,
      white:   37,

      on_black:   40,
      on_red:     41,
      on_green:   42,
      on_yellow:  43,
      on_blue:    44,
      on_magenta: 45,
      on_cyan:    46,
      on_white:   47,

      bright_black:   90,
      bright_red:     91,
      bright_green:   92,
      bright_yellow:  93,
      bright_blue:    94,
      bright_magenta: 95,
      bright_cyan:    96,
      bright_white:   97,

      on_bright_black:   100,
      on_bright_red:     101,
      on_bright_green:   102,
      on_bright_yellow:  103,
      on_bright_blue:    104,
      on_bright_magenta: 105,
      on_bright_cyan:    106,
      on_bright_white:   107
    }.freeze

    module_function

    def foreground?(code)
      [*(30..37), *(90..97)].include?(code.to_i)
    end

    def background?(code)
      [*(40..47), *(100..107)].include?(code.to_i)
    end

    def style?(code)
      (1..9).include?(code.to_i)
    end
  end # ANSI
end # Pastel

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
pastel-0.7.4 lib/pastel/ansi.rb
pokedex-terminal-0.2.8 vendor/bundle/ruby/2.7.0/gems/pastel-0.7.3/lib/pastel/ansi.rb
pokedex-terminal-0.2.7 vendor/bundle/ruby/2.7.0/gems/pastel-0.7.3/lib/pastel/ansi.rb
pokedex-terminal-0.2.6 vendor/bundle/ruby/2.7.0/gems/pastel-0.7.3/lib/pastel/ansi.rb
pokedex-terminal-0.2.5 vendor/bundle/ruby/2.7.0/gems/pastel-0.7.3/lib/pastel/ansi.rb
pokedex-terminal-0.2.4 vendor/bundle/ruby/2.7.0/gems/pastel-0.7.3/lib/pastel/ansi.rb
pastel-0.7.3 lib/pastel/ansi.rb
pastel-0.7.2 lib/pastel/ansi.rb
pastel-0.7.1 lib/pastel/ansi.rb