Class: OoxmlParser::RunProperties

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb

Overview

Data about ‘rPr` object

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(params = {}) ⇒ RunProperties

Returns a new instance of RunProperties.



59
60
61
62
63
64
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 59

def initialize(params = {})
  @font_name = params.fetch(:font_name, '')
  @font_style = FontStyle.new
  @baseline = :baseline
  super(parent: params[:parent])
end

Instance Attribute Details

#baselineSymbol (readonly)

Returns baseline of run.

Returns:

  • (Symbol)

    baseline of run



21
22
23
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 21

def baseline
  @baseline
end

#capsSymbol (readonly)

Returns caps data.

Returns:

  • (Symbol)

    caps data



25
26
27
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 25

def caps
  @caps
end

#colorRunSpacing

Returns get color.

Returns:



43
44
45
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 43

def color
  @color
end

#embossTrue, False (readonly)

Returns is text emboss.

Returns:

  • (True, False)

    is text emboss



33
34
35
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 33

def emboss
  @emboss
end

#font_colorColor, DocxColorScheme (readonly)

Returns color of run.

Returns:



17
18
19
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 17

def font_color
  @font_color
end

#font_styleFontStyle

Returns font style of run.

Returns:



15
16
17
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 15

def font_style
  @font_style
end

Returns hyperlink of run.

Returns:



23
24
25
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 23

def hyperlink
  @hyperlink
end

#languageValuedChild (readonly)

Returns language property.

Returns:



45
46
47
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 45

def language
  @language
end

#ligaturesValuedChild (readonly)

Returns ligatures type.

Returns:



53
54
55
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 53

def ligatures
  @ligatures
end

#outlineOutline (readonly)

Returns outline data.

Returns:



29
30
31
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 29

def outline
  @outline
end

#positionPosition

Returns position property.

Returns:



47
48
49
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 47

def position
  @position
end

#raw_nodeNokogiri::XML:Element (readonly)

Returns raw node value.

Returns:

  • (Nokogiri::XML:Element)

    raw node value



57
58
59
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 57

def raw_node
  @raw_node
end

#rtlTrue, False (readonly)

Returns is text rtl.

Returns:

  • (True, False)

    is text rtl



37
38
39
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 37

def rtl
  @rtl
end

#run_fontsRunFonts (readonly)

Returns value of RunFonts.

Returns:



55
56
57
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 55

def run_fonts
  @run_fonts
end

#run_styleRunStyle

Returns run style.

Returns:



51
52
53
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 51

def run_style
  @run_style
end

#shadeShade

Returns shade property.

Returns:

  • (Shade)

    shade property



49
50
51
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 49

def shade
  @shade
end

#shadowTrue, False (readonly)

Returns is text shadow.

Returns:

  • (True, False)

    is text shadow



31
32
33
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 31

def shadow
  @shadow
end

#sizeSize

Returns get run size.

Returns:

  • (Size)

    get run size



39
40
41
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 39

def size
  @size
end

#spaceOoxmlSize (readonly)

Returns space size.

Returns:



19
20
21
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 19

def space
  @space
end

#spacingRunSpacing

Returns get run spacing.

Returns:



41
42
43
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 41

def spacing
  @spacing
end

#vanishTrue, False (readonly)

Returns is text vanish.

Returns:

  • (True, False)

    is text vanish



35
36
37
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 35

def vanish
  @vanish
end

#vertical_alignSymbol (readonly)

Returns vertical align data.

Returns:

  • (Symbol)

    vertical align data



27
28
29
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 27

def vertical_align
  @vertical_align
end

Instance Method Details

#font_nameString

Returns name of font.

Returns:

  • (String)

    name of font



151
152
153
154
155
156
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 151

def font_name
  return @font_name unless @font_name.empty?
  return @run_fonts.ascii if @run_fonts

  root_object.default_font_typeface
end

#font_sizeFloat

Returns font size.

Returns:

  • (Float)

    font size



146
147
148
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 146

def font_size
  @font_size ||= root_object.default_font_size
end

#parse(node) ⇒ RunProperties

Parse RunProperties object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 69

def parse(node)
  @raw_node = node
  @font_style = root_object.default_font_style.dup
  node.attributes.each do |key, value|
    case key
    when 'sz'
      @font_size = value.value.to_f / 100.0
    when 'spc'
      @space = OoxmlSize.new(value.value.to_f, :one_100th_point)
    when 'b'
      @font_style.bold = option_enabled?(node, 'b')
    when 'i'
      @font_style.italic = option_enabled?(node, 'i')
    when 'u'
      @font_style.underlined = Underline.new(parent: self).parse(value.value)
    when 'strike'
      @font_style.strike = value_to_symbol(value)
    when 'baseline'
      @baseline = parse_baseline(value)
    when 'cap'
      @caps = value.value.to_sym
    end
  end
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'sz'
      @size = Size.new.parse(node_child)
    when 'shadow'
      @shadow = option_enabled?(node_child)
    when 'emboss'
      @emboss = option_enabled?(node_child)
    when 'vanish'
      @vanish = option_enabled?(node_child)
    when 'rtl'
      @rtl = option_enabled?(node_child)
    when 'spacing'
      @spacing = RunSpacing.new(parent: self).parse(node_child)
    when 'color'
      @color = OoxmlColor.new(parent: self).parse(node_child)
    when 'latin'
      @font_name = node_child.attribute('typeface').value
    when 'b'
      @font_style.bold = option_enabled?(node_child)
    when 'i'
      @font_style.italic = option_enabled?(node_child, 'i')
    when 'u'
      @font_style.underlined = Underline.new(:single)
    when 'vertAlign'
      @vertical_align_object = ValuedChild.new(:symbol, parent: self).parse(node_child)
      @vertical_align = @vertical_align_object.value
    when 'rFont'
      @font_name = node_child.attribute('val').value
    when 'rFonts'
      @run_fonts = RunFonts.new(parent: self).parse(node_child)
    when 'strike'
      @font_style.strike = option_enabled?(node_child)
    when 'hlinkClick'
      @hyperlink = Hyperlink.new(parent: self).parse(node_child)
    when 'ln'
      @outline = Outline.new(parent: self).parse(node_child)
    when 'lang'
      @language = ValuedChild.new(:string, parent: self).parse(node_child)
    when 'position'
      @position = Position.new(parent: self).parse(node_child)
    when 'shd'
      @shade = Shade.new(parent: self).parse(node_child)
    when 'rStyle'
      @run_style = RunStyle.new(parent: self).parse(node_child)
    when 'ligatures'
      @ligatures = ValuedChild.new(:symbol, parent: self).parse(node_child)
    end
  end
  @font_color = DocxColorScheme.new(parent: self).parse(node)
  self
end