File: constants.rb

package info (click to toggle)
ruby-ansi 1.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 404 kB
  • sloc: ruby: 1,880; makefile: 5
file content (25 lines) | stat: -rw-r--r-- 529 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module ANSI

  require 'ansi/chart'

  # Converts {CHART} and {SPECIAL_CHART} entries into constants.
  # So for example, the CHART entry for :red becomes:
  #
  #   ANSI::Constants::RED  #=> "\e[31m"
  #
  # The ANSI Constants are include into ANSI::Code and can be included
  # any where will they would be of use.
  #
  module Constants

    CHART.each do |name, code|
      const_set(name.to_s.upcase, "\e[#{code}m")
    end

    SPECIAL_CHART.each do |name, code|
      const_set(name.to_s.upcase, code)
    end

  end

end