Class: Uniword::Wordprocessingml::InstrText

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

Overview

Field instruction text

Generated from OOXML schema: wordprocessingml.yml Element: <w:instrText>

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ InstrText

Returns a new instance of InstrText.



24
25
26
27
28
29
30
31
32
33
# File 'lib/uniword/wordprocessingml/instr_text.rb', line 24

def initialize(attrs = {})
  if attrs.is_a?(Hash)
    text_val = attrs.delete(:text) || attrs[:content]
    if text_val.is_a?(String)
      attrs[:xml_space] = "preserve" if Text.preserve_whitespace?(text_val)
      attrs[:content] = [text_val] unless attrs.key?(:content)
    end
  end
  super
end

Instance Method Details

#textObject



35
36
37
# File 'lib/uniword/wordprocessingml/instr_text.rb', line 35

def text
  content&.join
end

#text=(value) ⇒ Object



39
40
41
# File 'lib/uniword/wordprocessingml/instr_text.rb', line 39

def text=(value)
  self.content = value.is_a?(Array) ? value : [value.to_s]
end

#to_sObject



43
44
45
# File 'lib/uniword/wordprocessingml/instr_text.rb', line 43

def to_s
  text.to_s
end