Class: OoxmlParser::OOXMLCoordinates
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::OOXMLCoordinates
- Defined in:
- lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb
Overview
Docx Coordinates
Instance Attribute Summary collapse
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#==(other) ⇒ True, False
Compare two OOXMLCoordinates objects.
-
#initialize(x_value = nil, y_value = nil, parent: nil) ⇒ OOXMLCoordinates
constructor
A new instance of OOXMLCoordinates.
-
#parse(node, x_attr: 'x', y_attr: 'y', unit: :dxa) ⇒ OOXMLCoordinates
Parse OOXMLCoordinates object.
-
#to_s ⇒ String
Result of convert of object to string.
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(x_value = nil, y_value = nil, parent: nil) ⇒ OOXMLCoordinates
Returns a new instance of OOXMLCoordinates.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb', line 8 def initialize(x_value = nil, y_value = nil, parent: nil) @x = if x_value.is_a?(OoxmlSize) x_value else OoxmlSize.new(x_value) end @y = if y_value.is_a?(OoxmlSize) y_value else OoxmlSize.new(y_value) end super(parent: parent) end |
Instance Attribute Details
#x ⇒ Object
Returns the value of attribute x.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb', line 6 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb', line 6 def y @y end |
Instance Method Details
#==(other) ⇒ True, False
Compare two OOXMLCoordinates objects
30 31 32 |
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb', line 30 def ==(other) x == other.x && y == other.y end |
#parse(node, x_attr: 'x', y_attr: 'y', unit: :dxa) ⇒ OOXMLCoordinates
Parse OOXMLCoordinates object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb', line 40 def parse(node, x_attr: 'x', y_attr: 'y', unit: :dxa) node.attributes.each do |key, value| case key when x_attr @x = OoxmlSize.new(value.value.to_f, unit) when y_attr @y = OoxmlSize.new(value.value.to_f, unit) end end self end |
#to_s ⇒ String
Returns result of convert of object to string.
23 24 25 |
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb', line 23 def to_s "(#{@x}; #{@y})" end |