Class: Colorin

Inherits:
String
  • Object
show all
Defined in:
lib/colorin.rb

Constant Summary collapse

VERSION =
'2.0.0'
STYLES =
configuration[:styles].freeze
DEFAULT_COLORS =
configuration[:default_colors].freeze
CUSTOM_COLORS =
configuration[:custom_colors].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.color_paletteObject



61
62
63
# File 'lib/colorin.rb', line 61

def self.color_palette
  DEFAULT_COLORS.keys.reject { |c| c.to_s.start_with? 'on_' }.map { |color| "#{Colorin.send "on_#{color}", '    ' }  #{Colorin.send color, color.to_s}" }
end

.custom_color_paletteObject



65
66
67
# File 'lib/colorin.rb', line 65

def self.custom_color_palette
  CUSTOM_COLORS.keys.map { |color| "#{Colorin.send "on_#{color}", '    ' }  #{Colorin.send color, color.to_s}" }
end

Instance Method Details

#hex(hex) ⇒ Object



53
54
55
# File 'lib/colorin.rb', line 53

def hex(hex)
  rgb *hex_to_rgb(hex)
end

#on_hex(hex) ⇒ Object



57
58
59
# File 'lib/colorin.rb', line 57

def on_hex(hex)
  on_rgb *hex_to_rgb(hex)
end

#on_rgb(r, g, b) ⇒ Object



49
50
51
# File 'lib/colorin.rb', line 49

def on_rgb(r, g, b)
  wrap "48;5;#{rgb_to_256(r, g, b)}"
end

#rgb(r, g, b) ⇒ Object



45
46
47
# File 'lib/colorin.rb', line 45

def rgb(r, g, b)
  wrap "38;5;#{rgb_to_256(r, g, b)}"
end