Class: OoxmlParser::SpacingValuedChild

Inherits:
OOXMLDocumentObject show all
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

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

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

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

This class inherits a constructor from OoxmlParser::OOXMLDocumentObject

Instance Attribute Details

#spacing_percentValuedChild (readonly)

Returns spacing percent.

Returns:



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_pointsValuedChild (readonly)

Returns spacing point.

Returns:



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

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:

  • (LineSpacing)

    result of parsing



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

#ruleSymbol

Returns rule used to determine line spacing.

Returns:

  • (Symbol)

    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_sizeOoxmlSize

Convert to OoxmlSize

Returns:



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