Module: NattyUI::Glyph

Defined in:
lib/natty-ui/glyph.rb

Overview

Helper class to select glyph types.

See Also:

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.default=(value) ⇒ Symbol (writeonly)

Define glyph type used by default.

Parameters:

  • value (Symbol)

    type name

Returns:

  • (Symbol)

    type name



13
14
15
# File 'lib/natty-ui/glyph.rb', line 13

def self.default=(value)
  @default = self[value.nil? || value == :default ? :point : value]
end

.namesArray<Symbol> (readonly)

Defined glyph type names.

Returns:

  • (Array<Symbol>)

    supported attribute names

See Also:



22
# File 'lib/natty-ui/glyph.rb', line 22

def self.names = @all.keys

Class Method Details

.[](name) ⇒ String

Returns glyph definition.

Parameters:

  • name (Symbol, #to_s)

    defined type name (see names) or glyph

Returns:

  • (String)

    glyph definition



28
29
30
31
32
33
34
35
36
37
# File 'lib/natty-ui/glyph.rb', line 28

def self.[](name)
  return @default if name == :default
  Text.embellish(
    if name.is_a?(Symbol)
      @all[name] or raise(ArgumentError, "invalid glyph type - #{name}")
    else
      name.to_s
    end
  )
end