Class: OoxmlParser::RunProperties
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::RunProperties
- Defined in:
- lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb
Overview
Data about ‘rPr` object
Instance Attribute Summary collapse
-
#baseline ⇒ Symbol
readonly
Baseline of run.
-
#caps ⇒ Symbol
readonly
Caps data.
-
#color ⇒ RunSpacing
Get color.
-
#emboss ⇒ True, False
readonly
Is text emboss.
-
#font_color ⇒ Color, DocxColorScheme
readonly
Color of run.
-
#font_style ⇒ FontStyle
Font style of run.
-
#hyperlink ⇒ Hyperlink
readonly
Hyperlink of run.
-
#language ⇒ ValuedChild
readonly
Language property.
-
#ligatures ⇒ ValuedChild
readonly
Ligatures type.
-
#outline ⇒ Outline
readonly
Outline data.
-
#position ⇒ Position
Position property.
-
#raw_node ⇒ Nokogiri::XML:Element
readonly
Raw node value.
-
#rtl ⇒ True, False
readonly
Is text rtl.
-
#run_fonts ⇒ RunFonts
readonly
Value of RunFonts.
-
#run_style ⇒ RunStyle
Run style.
-
#shade ⇒ Shade
Shade property.
-
#shadow ⇒ True, False
readonly
Is text shadow.
-
#size ⇒ Size
Get run size.
-
#space ⇒ OoxmlSize
readonly
Space size.
-
#spacing ⇒ RunSpacing
Get run spacing.
-
#vanish ⇒ True, False
readonly
Is text vanish.
-
#vertical_align ⇒ Symbol
readonly
Vertical align data.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#font_name ⇒ String
Name of font.
-
#font_size ⇒ Float
Font size.
-
#initialize(params = {}) ⇒ RunProperties
constructor
A new instance of RunProperties.
-
#parse(node) ⇒ RunProperties
Parse RunProperties object.
Methods inherited from OOXMLDocumentObject
#==, #boolean_attribute_value, #parse_xml, #with_data?
Methods included from OoxmlObjectAttributeHelper
#attribute_enabled?, #option_enabled?
Methods included from OoxmlDocumentObjectHelper
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
#baseline ⇒ Symbol (readonly)
Returns 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 |
#caps ⇒ Symbol (readonly)
Returns 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 |
#color ⇒ RunSpacing
Returns get color.
43 44 45 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 43 def color @color end |
#emboss ⇒ True, False (readonly)
Returns 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_color ⇒ Color, DocxColorScheme (readonly)
Returns color of run.
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_style ⇒ FontStyle
Returns font style of run.
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 |
#hyperlink ⇒ Hyperlink (readonly)
Returns hyperlink of run.
23 24 25 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 23 def hyperlink @hyperlink end |
#language ⇒ ValuedChild (readonly)
Returns language property.
45 46 47 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 45 def language @language end |
#ligatures ⇒ ValuedChild (readonly)
Returns ligatures type.
53 54 55 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 53 def ligatures @ligatures end |
#outline ⇒ Outline (readonly)
Returns outline data.
29 30 31 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 29 def outline @outline end |
#position ⇒ Position
Returns position property.
47 48 49 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 47 def position @position end |
#raw_node ⇒ Nokogiri::XML:Element (readonly)
Returns 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 |
#rtl ⇒ True, False (readonly)
Returns 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_fonts ⇒ RunFonts (readonly)
Returns value of RunFonts.
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_style ⇒ RunStyle
Returns run style.
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 |
#shade ⇒ Shade
Returns 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 |
#shadow ⇒ True, False (readonly)
Returns 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 |
#size ⇒ Size
Returns 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 |
#space ⇒ OoxmlSize (readonly)
Returns space size.
19 20 21 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 19 def space @space end |
#spacing ⇒ RunSpacing
Returns get run spacing.
41 42 43 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb', line 41 def spacing @spacing end |
#vanish ⇒ True, False (readonly)
Returns 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_align ⇒ Symbol (readonly)
Returns 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_name ⇒ String
Returns 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_size ⇒ Float
Returns 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
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 |