class Dev::UI::Glyph

Constants

CHECK

GREEN CHECK MARK (✓)

INFO

BLUE MATHEMATICAL SCRIPT SMALL i (𝒾)

MAP

Mapping of glyphs to terminal output

QUESTION

BLUE QUESTION MARK (?)

STAR

YELLOw SMALL STAR (⭑)

X

RED BALLOT X (✗)

Attributes

char[R]
codepoint[R]
color[R]
fmt[R]
handle[R]
to_s[R]

Public Class Methods

available() click to toggle source

All available glyphs by name

# File lib/dev/ui/glyph.rb, line 69
def self.available
  MAP.keys
end
lookup(name) click to toggle source

Looks up a glyph by name

Raises

Raises a InvalidGlyphHandle if the glyph is not available You likely need to create it with .new or you made a typo

Returns

Returns a terminal output-capable string

# File lib/dev/ui/glyph.rb, line 61
def self.lookup(name)
  MAP.fetch(name.to_s)
rescue KeyError
  raise InvalidGlyphHandle, name
end
new(handle, codepoint, color) click to toggle source

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)

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

# File lib/dev/ui/glyph.rb, line 28
def initialize(handle, codepoint, color)
  @handle    = handle
  @codepoint = codepoint
  @color     = color
  @char      = [codepoint].pack('U')
  @to_s      = color.code + char + Color::RESET.code
  @fmt       = "{{#{color.name}:#{char}}}"

  MAP[handle] = self
end