Class: Tgui::ThemeComponent

Inherits:
Object show all
Extended by:
ThemeAttributed
Includes:
BangNest
Defined in:
lib/white_gold/convention/theme/theme_component.rb

Direct Known Subclasses

Widget::Theme

Constant Summary

Constants included from ThemeAttributed

Tgui::ThemeAttributed::ATTRIBUTE_TYPES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ThemeAttributed

theme_attr, theme_comp

Methods included from BangDef

#def!

Methods included from BangNest

#method_missing, #respond_to?

Methods included from BangNestedCaller

#bang_method_missing, #bang_object_stack, #bang_respond_to?, #self!, #upon!

Constructor Details

#initialize(name, custom_name) ⇒ ThemeComponent

Returns a new instance of ThemeComponent.



8
9
10
11
12
# File 'lib/white_gold/convention/theme/theme_component.rb', line 8

def initialize name, custom_name
  @name = name
  @custom_name = custom_name
  @attributes = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class BangNest

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



14
15
16
# File 'lib/white_gold/convention/theme/theme_component.rb', line 14

def name
  @name
end

Instance Method Details

#base_nameObject



20
21
22
# File 'lib/white_gold/convention/theme/theme_component.rb', line 20

def base_name
  @name || default_name
end

#default_nameObject



16
17
18
# File 'lib/white_gold/convention/theme/theme_component.rb', line 16

def default_name
  self.class.name.split("::")[-2]
end

#to_themeObject



28
29
30
31
32
# File 'lib/white_gold/convention/theme/theme_component.rb', line 28

def to_theme
  return "" if @attributes.empty? && !@custom_name
  header = @custom_name ? "#{@custom_name} : #{base_name}" : name
  "#{header} {\n#{@attributes.values.map(&:to_theme).join("\n")}\n}"
end