Class: Uniword::Properties::StyleReference

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/uniword/properties/style_reference.rb

Overview

Style reference element for paragraph styles

Represents <w:pStyle w:val="..."/> where value is the style ID

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cast(value) ⇒ Object

Cast raw style-id strings into references (mirrors Text.cast), so properties.style = "Heading1" stores a proper StyleReference



22
23
24
25
26
27
28
29
30
31
# File 'lib/uniword/properties/style_reference.rb', line 22

def self.cast(value)
  case value
  when StyleReference, nil
    value
  when String
    new(value: value)
  else
    super
  end
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?

Compare with another StyleReference or a string



34
35
36
37
38
39
40
41
42
# File 'lib/uniword/properties/style_reference.rb', line 34

def ==(other)
  if other.is_a?(StyleReference)
    value == other.value
  elsif other.is_a?(String)
    value == other
  else
    super
  end
end

#hashObject

For hash key compatibility



52
53
54
# File 'lib/uniword/properties/style_reference.rb', line 52

def hash
  value.hash
end

#to_sObject

For string interpolation and general string-like behavior



47
48
49
# File 'lib/uniword/properties/style_reference.rb', line 47

def to_s
  value.to_s
end