Class: CLI::UI::Glyph
Defined Under Namespace
Classes: InvalidGlyphHandle
Constant Summary collapse
- MAP =
Mapping of glyphs to terminal output
{}
- STAR =
YELLOW SMALL STAR (โญ)
new('*', 0x2b51, '*', Color::YELLOW)
- INFO =
BLUE MATHEMATICAL SCRIPT SMALL i (๐พ)
new('i', 0x1d4be, 'i', Color::BLUE)
- QUESTION =
BLUE QUESTION MARK (?)
new('?', 0x003f, '?', Color::BLUE)
- CHECK =
GREEN CHECK MARK (โ)
new('v', 0x2713, 'โ', Color::GREEN)
- X =
RED BALLOT X (โ)
new('x', 0x2717, 'X', Color::RED)
- BUG =
Bug emoji (๐)
new('b', 0x1f41b, '!', Color::WHITE)
- CHEVRON =
RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK (ยป)
new('>', 0xbb, 'ยป', Color::YELLOW)
- HOURGLASS =
HOURGLASS + VARIATION SELECTOR 15 (โ๏ธ)
new('H', [0x231b, 0xfe0e], 'H', Color::BLUE)
- WARNING =
WARNING SIGN + VARIATION SELECTOR 16 (โ ๏ธ )
new('!', [0x26a0, 0xfe0f], '!', Color::YELLOW)
Instance Attribute Summary collapse
-
#char ⇒ Object
readonly
Returns the value of attribute char.
-
#codepoint ⇒ Object
readonly
Returns the value of attribute codepoint.
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#fmt ⇒ Object
readonly
Returns the value of attribute fmt.
-
#handle ⇒ Object
readonly
Returns the value of attribute handle.
-
#to_s ⇒ Object
readonly
Returns the value of attribute to_s.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(handle, codepoint, plain, color) ⇒ Glyph
constructor
A new instance of Glyph.
Methods included from T::Sig
Constructor Details
#initialize(handle, codepoint, plain, color) ⇒ Glyph
Returns a new instance of Glyph.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/cli/ui/glyph.rb', line 46 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 |
Instance Attribute Details
#char ⇒ Object (readonly)
Returns the value of attribute char.
28 29 30 |
# File 'lib/cli/ui/glyph.rb', line 28 def char @char end |
#codepoint ⇒ Object (readonly)
Returns the value of attribute codepoint.
31 32 33 |
# File 'lib/cli/ui/glyph.rb', line 31 def codepoint @codepoint end |
#color ⇒ Object (readonly)
Returns the value of attribute color.
34 35 36 |
# File 'lib/cli/ui/glyph.rb', line 34 def color @color end |
#fmt ⇒ Object (readonly)
Returns the value of attribute fmt.
28 29 30 |
# File 'lib/cli/ui/glyph.rb', line 28 def fmt @fmt end |
#handle ⇒ Object (readonly)
Returns the value of attribute handle.
28 29 30 |
# File 'lib/cli/ui/glyph.rb', line 28 def handle @handle end |
#to_s ⇒ Object (readonly)
Returns the value of attribute to_s.
28 29 30 |
# File 'lib/cli/ui/glyph.rb', line 28 def to_s @to_s end |
Class Method Details
.available ⇒ Object
91 92 93 |
# File 'lib/cli/ui/glyph.rb', line 91 def available MAP.keys end |
.lookup(name) ⇒ Object
82 83 84 85 86 |
# File 'lib/cli/ui/glyph.rb', line 82 def lookup(name) MAP.fetch(name.to_s) rescue KeyError raise InvalidGlyphHandle, name end |