Class: OoxmlParser::DocxDrawingDistanceFromText

Inherits:
Object
  • Object
show all
Defined in:
lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_distance_from_text.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#bottomObject

Returns the value of attribute bottom.



4
5
6
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_distance_from_text.rb', line 4

def bottom
  @bottom
end

#leftObject

Returns the value of attribute left.



4
5
6
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_distance_from_text.rb', line 4

def left
  @left
end

#rightObject

Returns the value of attribute right.



4
5
6
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_distance_from_text.rb', line 4

def right
  @right
end

#topObject

Returns the value of attribute top.



4
5
6
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_distance_from_text.rb', line 4

def top
  @top
end

Class Method Details

.parse(distance_node) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_distance_from_text.rb', line 6

def self.parse(distance_node)
  distance_from_text = DocxDrawingDistanceFromText.new
  distance_node.attributes.each do |key, value|
    case key
    when 'distT'
      distance_from_text.top = (value.value.to_f / 360_000.0).round(2)
    when 'distB'
      distance_from_text.bottom = (value.value.to_f / 360_000.0).round(2)
    when 'distL'
      distance_from_text.left = (value.value.to_f / 360_000.0).round(2)
    when 'distR'
      distance_from_text.right = (value.value.to_f / 360_000.0).round(2)
    end
  end
  distance_from_text
end