Class: Uniword::Themes::ThemeVariant
- Inherits:
-
Object
- Object
- Uniword::Themes::ThemeVariant
- Defined in:
- lib/uniword/theme/theme_variant.rb
Overview
Represents a theme variant
Theme variants provide visual style variations of a base theme. In .thmx files, variants are numbered (variant1, variant2, etc.) and each contains a complete theme definition that can override the base theme’s colors, fonts, or effects.
Instance Attribute Summary collapse
-
#guid ⇒ String?
Variant GUID from theme package.
-
#id ⇒ String
Variant identifier (e.g., ‘variant1’, ‘variant2’).
-
#theme ⇒ Theme?
Parsed theme for this variant.
-
#theme_xml ⇒ String?
Raw theme XML for this variant.
Instance Method Summary collapse
-
#apply_to(base_theme) ⇒ Theme
Apply this variant to a base theme.
-
#initialize(id, theme_xml: nil) ⇒ ThemeVariant
constructor
Initialize a theme variant.
-
#inspect ⇒ String
Provide detailed inspection for debugging.
-
#name ⇒ String
Get a descriptive name for this variant.
-
#parse_theme ⇒ Theme
Parse the variant theme XML.
Constructor Details
#initialize(id, theme_xml: nil) ⇒ ThemeVariant
Initialize a theme variant
33 34 35 36 37 38 |
# File 'lib/uniword/theme/theme_variant.rb', line 33 def initialize(id, theme_xml: nil) @id = id @theme_xml = theme_xml @theme = nil @guid = nil end |
Instance Attribute Details
#guid ⇒ String?
Returns Variant GUID from theme package.
21 22 23 |
# File 'lib/uniword/theme/theme_variant.rb', line 21 def guid @guid end |
#id ⇒ String
Returns Variant identifier (e.g., ‘variant1’, ‘variant2’).
18 19 20 |
# File 'lib/uniword/theme/theme_variant.rb', line 18 def id @id end |
#theme ⇒ Theme?
Returns Parsed theme for this variant.
27 28 29 |
# File 'lib/uniword/theme/theme_variant.rb', line 27 def theme @theme end |
#theme_xml ⇒ String?
Returns Raw theme XML for this variant.
24 25 26 |
# File 'lib/uniword/theme/theme_variant.rb', line 24 def theme_xml @theme_xml end |
Instance Method Details
#apply_to(base_theme) ⇒ Theme
Apply this variant to a base theme
For now, this simply returns the variant’s theme since variants in .thmx files are complete theme definitions. Future enhancement: merge variant with base theme selectively.
59 60 61 62 63 64 65 66 |
# File 'lib/uniword/theme/theme_variant.rb', line 59 def apply_to(base_theme) # Parse theme if not already parsed parse_theme unless @theme # Return the variant theme # In .thmx files, variants are complete themes, not just overrides @theme || base_theme.dup end |
#inspect ⇒ String
Provide detailed inspection for debugging
80 81 82 83 84 |
# File 'lib/uniword/theme/theme_variant.rb', line 80 def inspect "#<Uniword::Theme::ThemeVariant id=#{@id.inspect} " \ "guid=#{@guid.inspect} " \ "theme=#{@theme ? @theme.name : 'not parsed'}>" end |
#name ⇒ String
Get a descriptive name for this variant
71 72 73 74 75 |
# File 'lib/uniword/theme/theme_variant.rb', line 71 def name # In the future, this could map to display names # For now, just return the ID @id end |
#parse_theme ⇒ Theme
Parse the variant theme XML
43 44 45 46 47 48 49 |
# File 'lib/uniword/theme/theme_variant.rb', line 43 def parse_theme return @theme if @theme return nil unless @theme_xml parser = ThemeXmlParser.new @theme = parser.parse(@theme_xml) end |