class HighLine::ColorScheme


end
i = !i
end
say(“<%= color(‘#{row}’, :odd_row) %>”)
else
say(“<%= color(‘#{row}’, :even_row ) %>”)
if i then
(“A”..“D”).each do |row|
i = true
say(“<%= color(‘-’*20, :horizontal_line) %>”)
say(“<%= color(‘Headline’, :headline) %>”)
HighLine.color_scheme = ft<br><br>end<br>cs = [ :magenta ]
= [ :green ]
= [ :bold, :white ]
= [ :bold, :yellow, :on_black ]
ft = HighLine::ColorScheme.new do |cs|
and using it:
@example Instantiating a color scheme, applying it to HighLine,
A ColorScheme contains named sets of HighLine color constants.
color(“This is a warning”, :warning)
has a :warning color then the following could be used:
{HighLine.color} method call. For example, by applying a ColorScheme that
ColorScheme objects encapsulate a named set of colors to be used in the

def [](color_tag)

Returns:
  • (Style) -

Parameters:
  • color_tag (#to_sym) --
def [](color_tag)
  @scheme[to_symbol(color_tag)]
end

def []=(color_tag, constants)

Parameters:
  • constants (Array) -- Array of Style symbols
  • color_tag (#to_sym) --
def []=(color_tag, constants)
  @scheme[to_symbol(color_tag)] =
    HighLine::Style.new(name: color_tag.to_s.downcase.to_sym,
                        list: constants,
                        no_index: true)
end

def definition(color_tag)

Parameters:
  • color_tag (#to_sym) --
def definition(color_tag)
  style = @scheme[to_symbol(color_tag)]
  style && style.list
end

def include?(color_tag)

Returns:
  • (Boolean) -

Parameters:
  • color_tag (#to_sym) --
def include?(color_tag)
  @scheme.keys.include?(to_symbol(color_tag))
end

def initialize(h = nil)

Parameters:
  • h (Hash) --
def initialize(h = nil)
  @scheme = {}
  load_from_hash(h) if h
  yield self if block_given?
end

def keys

Returns:
  • (Array) - of keys
def keys
  @scheme.keys
end

def load_from_hash(h)

Parameters:
  • h (Hash) --
def load_from_hash(h)
  h.each_pair do |color_tag, constants|
    self[color_tag] = constants
  end
end

def to_constant(v)

Return a normalized representation of a color setting.
def to_constant(v)
  v = v.to_s if v.is_a?(Symbol)
  if v.is_a?(::String)
    HighLine.const_get(v.upcase)
  else
    v
  end
end

def to_hash

Returns:
  • (Hash) - scheme as Hash. It may be reused in a new ColorScheme.
def to_hash
  @scheme.each_with_object({}) do |pair, hsh|
    key, value = pair
    hsh[key] = value.list
  end
end

def to_symbol(t)

Return a normalized representation of a color name.
def to_symbol(t)
  t.to_s.downcase
end