Module: Colorize::ClassMethods

### Home Classes Methods

### In Files

- lib/colorize/class_methods.rb

### Methods

- #color_codes
- #color_matrix
- #color_methods
- #color_samples
- #colors
- #disable_colorization
- #disable_colorization=
- #mode_codes
- #modes
- #modes_methods

### Class/Module Index

Quicksearch

- Colorize
- Colorize::ClassMethods
- Colorize::InstanceMethods
- String

No matching classes.

# Colorize::ClassMethods

### Public Instance Methods

color_codes() click to toggle source

Color codes hash

    # File lib/colorize/class_methods.rb, line 25
    def color_codes
      {
        :black   => 0, :light_black    => 60,
        :red     => 1, :light_red      => 61,
        :green   => 2, :light_green    => 62,
        :yellow  => 3, :light_yellow   => 63,
        :blue    => 4, :light_blue     => 64,
        :magenta => 5, :light_magenta  => 65,
        :cyan    => 6, :light_cyan     => 66,
        :white   => 7, :light_white    => 67,
        :default => 9
      }
    end

color_matrix(txt = '') click to toggle source

Method removed, raise NoMethodError

    # File lib/colorize/class_methods.rb, line 110
    def color_matrix(txt = '')
      fail NoMethodError, '#color_matrix method was removed, try #color_samples instead'
    end

color_methods() click to toggle source

Color and on_color methods

    # File lib/colorize/class_methods.rb, line 70
    def color_methods
      colors.each do |key|
        next if key == :default

        define_method key do
          colorize(:color => key)
        end

        define_method "on_#{key}" do
          colorize(:background => key)
        end
      end
    end

color_samples() click to toggle source

Display color samples

    # File lib/colorize/class_methods.rb, line 100
    def color_samples
      colors.permutation(2).each do |background, color|
        sample_text = "#{color.inspect.rjust(15)} on #{background.inspect.ljust(15)}"
        puts "#{sample_text.colorize(:color => color, :background => background)} #{sample_text}"
      end
    end

colors() click to toggle source

Return array of available colors used by colorize

    # File lib/colorize/class_methods.rb, line 42
    def colors
      color_codes.keys
    end

disable_colorization(value = nil) click to toggle source

Property to disable colorization

    # File lib/colorize/class_methods.rb, line 7
    def disable_colorization(value = nil)
      if value.nil?
        @disable_colorization || false
      else
        @disable_colorization = (value || false)
      end
    end

disable_colorization=(value) click to toggle source

Setter for disable colorization

    # File lib/colorize/class_methods.rb, line 18
    def disable_colorization=(value)
      @disable_colorization = (value || false)
    end

mode_codes() click to toggle source

Mode codes hash

    # File lib/colorize/class_methods.rb, line 49
    def mode_codes
      {
        :default   => 0, # Turn off all attributes
        :bold      => 1, # Set bold mode
        :underline => 4, # Set underline mode
        :blink     => 5, # Set blink mode
        :swap      => 7, # Exchange foreground and background colors
        :hide      => 8  # Hide text (foreground color would be the same as background)
      }
    end

modes() click to toggle source

Return array of available modes used by colorize

    # File lib/colorize/class_methods.rb, line 63
    def modes
      mode_codes.keys
    end

modes_methods() click to toggle source

Modes methods

    # File lib/colorize/class_methods.rb, line 87
    def modes_methods
      modes.each do |key|
        next if key == :default

        define_method key do
          colorize(:mode => key)
        end
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.