Class: Uniword::Styles::SemanticStyle

Inherits:
ParagraphStyleDefinition show all
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

Attributes inherited from ParagraphStyleDefinition

#next_style, #run_properties

Attributes inherited from StyleDefinition

#base_style, #name

Instance Method Summary collapse

Methods inherited from ParagraphStyleDefinition

#resolve_inheritance

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_typeObject (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_propertiesHash

Get all properties including semantic type

Returns:

  • (Hash)

    All style 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

Returns:

  • (Boolean)

    True if semantic type is valid



36
37
38
# File 'lib/uniword/wordprocessingml/styles/semantic_style.rb', line 36

def valid_semantic?
  SEMANTIC_TYPES.include?(@semantic_type)
end