Class: Tgui::ThemeComponent
- Extended by:
- ThemeAttributed
- Includes:
- BangNest
- Defined in:
- lib/white_gold/convention/theme/theme_component.rb
Direct Known Subclasses
Constant Summary
Constants included from ThemeAttributed
Tgui::ThemeAttributed::ATTRIBUTE_TYPES
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #base_name ⇒ Object
- #default_name ⇒ Object
-
#initialize(name, custom_name) ⇒ ThemeComponent
constructor
A new instance of ThemeComponent.
- #to_theme ⇒ Object
Methods included from ThemeAttributed
Methods included from BangDef
Methods included from BangNest
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
#name ⇒ Object (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_name ⇒ Object
20 21 22 |
# File 'lib/white_gold/convention/theme/theme_component.rb', line 20 def base_name @name || default_name end |
#default_name ⇒ Object
16 17 18 |
# File 'lib/white_gold/convention/theme/theme_component.rb', line 16 def default_name self.class.name.split("::")[-2] end |
#to_theme ⇒ Object
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 |