Class: Uniword::Styles::SemanticStyle
- Inherits:
-
ParagraphStyleDefinition
- Object
- StyleDefinition
- ParagraphStyleDefinition
- Uniword::Styles::SemanticStyle
- Defined in:
- lib/uniword/wordprocessingml/styles/semantic_style.rb
Overview
Semantic style definition
Responsibility: Hold semantic style properties Single Responsibility: Semantic style configuration only
Extends paragraph styles with semantic meaning for special content types like terms, definitions, examples, notes, etc.
Constant Summary collapse
- SEMANTIC_TYPES =
%i[ term definition example note warning caution code_example formula reference ].freeze
Instance Attribute Summary collapse
-
#semantic_type ⇒ Object
readonly
Returns the value of attribute semantic_type.
Attributes inherited from ParagraphStyleDefinition
Attributes inherited from StyleDefinition
Instance Method Summary collapse
-
#full_properties ⇒ Hash
Get all properties including semantic type.
-
#initialize(config) ⇒ SemanticStyle
constructor
A new instance of SemanticStyle.
-
#valid_semantic? ⇒ Boolean
Check if this is a valid semantic style.
Methods inherited from ParagraphStyleDefinition
Methods inherited from StyleDefinition
#properties, #resolve_inheritance
Constructor Details
#initialize(config) ⇒ SemanticStyle
Returns a new instance of SemanticStyle.
27 28 29 30 31 |
# File 'lib/uniword/wordprocessingml/styles/semantic_style.rb', line 27 def initialize(config) super @semantic_type = config[:semantic]&.to_sym validate_semantic_type! end |
Instance Attribute Details
#semantic_type ⇒ Object (readonly)
Returns the value of attribute semantic_type.
13 14 15 |
# File 'lib/uniword/wordprocessingml/styles/semantic_style.rb', line 13 def semantic_type @semantic_type end |
Instance Method Details
#full_properties ⇒ Hash
Get all properties including semantic type
43 44 45 |
# File 'lib/uniword/wordprocessingml/styles/semantic_style.rb', line 43 def full_properties super.merge(semantic: @semantic_type) end |
#valid_semantic? ⇒ Boolean
Check if this is a valid semantic style
36 37 38 |
# File 'lib/uniword/wordprocessingml/styles/semantic_style.rb', line 36 def valid_semantic? SEMANTIC_TYPES.include?(@semantic_type) end |