Module: NattyUI::Frame

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

Overview

Helper class to select frame types.

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.default=(value) ⇒ Symbol (writeonly)

Define frame type used by default.

Parameters:

  • value (Symbol)

    type name

Returns:

  • (Symbol)

    type name



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

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

.namesArray<Symbol> (readonly)

Defined frame type names.

Returns:

  • (Array<Symbol>)

    supported attribute names

See Also:



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

def self.names = @all.keys

Class Method Details

.[](name) ⇒ String

Returns frame definition.

Parameters:

  • name (Symbol, String)

    defined type name (see names) or frame elements

Returns:

  • (String)

    frame definition

Raises:

  • (ArgumentError)


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

def self.[](name)
  return @default if name == :default
  if name.is_a?(Symbol)
    ret = @all[name] and return ret
  elsif name.is_a?(String)
    return name if name.size == 11
    return name * 11 if name.size == 1
  end
  raise(ArgumentError, "invalid frame type - #{name}")
end