Class: OoxmlParser::SpacingValuedChild
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::SpacingValuedChild
- Defined in:
- lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/spacing/spacing_valued_child.rb
Overview
Class to describe spacing valued child
Instance Attribute Summary collapse
-
#spacing_percent ⇒ ValuedChild
readonly
Spacing percent.
-
#spacing_points ⇒ ValuedChild
readonly
Spacing point.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#parse(node) ⇒ LineSpacing
Parse LineSpacing object.
-
#rule ⇒ Symbol
Rule used to determine line spacing.
-
#to_ooxml_size ⇒ OoxmlSize
Convert to OoxmlSize.
Methods inherited from OOXMLDocumentObject
#==, #boolean_attribute_value, #initialize, #parse_xml, #with_data?
Methods included from OoxmlObjectAttributeHelper
#attribute_enabled?, #option_enabled?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
This class inherits a constructor from OoxmlParser::OOXMLDocumentObject
Instance Attribute Details
#spacing_percent ⇒ ValuedChild (readonly)
Returns spacing percent.
7 8 9 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/spacing/spacing_valued_child.rb', line 7 def spacing_percent @spacing_percent end |
#spacing_points ⇒ ValuedChild (readonly)
Returns spacing point.
9 10 11 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/spacing/spacing_valued_child.rb', line 9 def spacing_points @spacing_points end |
Instance Method Details
#parse(node) ⇒ LineSpacing
Parse LineSpacing object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/spacing/spacing_valued_child.rb', line 14 def parse(node) node.xpath('*').each do |node_child| case node_child.name when 'spcPct' @spacing_percent = ValuedChild.new(:float, parent: self).parse(node_child) when 'spcPts' @spacing_points = ValuedChild.new(:float, parent: self).parse(node_child) end end self end |
#rule ⇒ Symbol
Returns rule used to determine line spacing.
36 37 38 39 40 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/spacing/spacing_valued_child.rb', line 36 def rule return :multiple if @spacing_percent :exact end |
#to_ooxml_size ⇒ OoxmlSize
Convert to OoxmlSize
28 29 30 31 32 33 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/spacing/spacing_valued_child.rb', line 28 def to_ooxml_size return OoxmlSize.new(@spacing_percent.value, :one_1000th_percent) if @spacing_percent return OoxmlSize.new(@spacing_points.value, :spacing_point) if @spacing_points raise 'Unknown spacing child type' end |