Class: Dex::UI::Glyph
- Inherits:
-
Object
- Object
- Dex::UI::Glyph
- Defined in:
- lib/dex/ui/glyph.rb
Defined Under Namespace
Classes: InvalidGlyphHandle
Constant Summary collapse
- MAP =
{}
- STAR =
BLACK SMALL STAR
new('*', 0x2b51, Color::YELLOW)
- INFO =
MATHEMATICAL SCRIPT SMALL I
new('i', 0x1d4be, Color::BLUE)
- QUESTION =
QUESTION MARK
new('?', 0x003f, Color::BLUE)
- CHECK =
CHECK MARK
new('v', 0x2713, Color::GREEN)
- X =
BALLOT X
new('x', 0x2717, Color::RED)
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, color) ⇒ Glyph
constructor
A new instance of Glyph.
Constructor Details
#initialize(handle, codepoint, color) ⇒ Glyph
Returns a new instance of Glyph.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/dex/ui/glyph.rb', line 9 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 |
Instance Attribute Details
#char ⇒ Object (readonly)
Returns the value of attribute char.
8 9 10 |
# File 'lib/dex/ui/glyph.rb', line 8 def char @char end |
#codepoint ⇒ Object (readonly)
Returns the value of attribute codepoint.
8 9 10 |
# File 'lib/dex/ui/glyph.rb', line 8 def codepoint @codepoint end |
#color ⇒ Object (readonly)
Returns the value of attribute color.
8 9 10 |
# File 'lib/dex/ui/glyph.rb', line 8 def color @color end |
#fmt ⇒ Object (readonly)
Returns the value of attribute fmt.
8 9 10 |
# File 'lib/dex/ui/glyph.rb', line 8 def fmt @fmt end |
#handle ⇒ Object (readonly)
Returns the value of attribute handle.
8 9 10 |
# File 'lib/dex/ui/glyph.rb', line 8 def handle @handle end |
#to_s ⇒ Object (readonly)
Returns the value of attribute to_s.
8 9 10 |
# File 'lib/dex/ui/glyph.rb', line 8 def to_s @to_s end |
Class Method Details
.available ⇒ Object
44 45 46 |
# File 'lib/dex/ui/glyph.rb', line 44 def self.available MAP.keys end |
.lookup(name) ⇒ Object
38 39 40 41 42 |
# File 'lib/dex/ui/glyph.rb', line 38 def self.lookup(name) MAP.fetch(name.to_s) rescue KeyError raise InvalidGlyphHandle, name end |