Method: CLI::UI::Glyph#initialize

Defined in:
lib/cli/ui/glyph.rb

#initialize(handle, codepoint, plain, color) ⇒ Glyph

Creates a new glyph

Attributes

  • handle - The handle in the MAP constant

  • codepoint - The codepoint used to create the glyph (e.g. 0x2717 for a ballot X)

  • plain - A fallback plain string to be used in case glyphs are disabled

  • color - What color to output the glyph. Check CLI::UI::Color for options.

: (String handle, (Integer | Array) codepoint, String plain, Color color) -> void



43
44
45
46
47
48
49
50
51
52
# File 'lib/cli/ui/glyph.rb', line 43

def initialize(handle, codepoint, plain, color)
  @handle    = handle
  @codepoint = codepoint
  @color     = color
  @char      = CLI::UI::OS.current.use_emoji? ? Array(codepoint).pack('U*') : plain
  @to_s      = color.code + @char + Color::RESET.code
  @fmt       = "{{#{color.name}:#{@char}}}"

  MAP[handle] = self
end