Class: OoxmlParser::DocxShapeSize

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb

Overview

Docx Shape Size

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

#child_extentOOXMLCoordinates (readonly)

Returns child extent.

Returns:



15
16
17
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb', line 15

def child_extent
  @child_extent
end

#child_offsetOOXMLCoordinates (readonly)

Returns child offset.

Returns:



13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb', line 13

def child_offset
  @child_offset
end

#extentOOXMLCoordinates (readonly) Also known as: extents

Returns extent info.

Returns:



11
12
13
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb', line 11

def extent
  @extent
end

#flip_horizontalTrue, False (readonly)

Returns is image flipped horizontally.

Returns:

  • (True, False)

    is image flipped horizontally



17
18
19
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb', line 17

def flip_horizontal
  @flip_horizontal
end

#flip_verticalTrue, False (readonly)

Returns is image flipped vertically.

Returns:

  • (True, False)

    is image flipped vertically



19
20
21
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb', line 19

def flip_vertical
  @flip_vertical
end

#offsetOOXMLCoordinates (readonly)

Returns offset info.

Returns:



9
10
11
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb', line 9

def offset
  @offset
end

#rotationOoxmlSize (readonly)

Returns rotation info.

Returns:



7
8
9
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb', line 7

def rotation
  @rotation
end

Instance Method Details

#parse(node) ⇒ DocxShapeSize

Parse DocxShapeSize object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb', line 26

def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'rot'
      @rotation = OoxmlSize.new(value.value.to_f, :one_60000th_degree)
    when 'flipH'
      @flip_horizontal = attribute_enabled?(value)
    when 'flipV'
      @flip_vertical = attribute_enabled?(value)
    end
  end
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'off'
      @offset = OOXMLCoordinates.new(parent: self).parse(node_child, unit: :emu)
    when 'ext'
      @extent = OOXMLCoordinates.new(parent: self).parse(node_child, x_attr: 'cx', y_attr: 'cy', unit: :emu)
    when 'chOff'
      @child_offset = OOXMLCoordinates.new(parent: self).parse(node_child, unit: :emu)
    when 'chExt'
      @child_extent = OOXMLCoordinates.new(parent: self).parse(node_child, x_attr: 'cx', y_attr: 'cy', unit: :emu)
    end
  end
  self
end