Class: OoxmlParser::OOXMLCoordinates
- Inherits:
-
Object
- Object
- OoxmlParser::OOXMLCoordinates
- Defined in:
- lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb
Instance Attribute Summary collapse
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Class Method Summary collapse
-
.parse(position_node, x_attr: 'x', y_attr: 'y', unit: :dxa) ⇒ OOXMLCoordinates
Parse OOXMLCoordinates object.
Instance Method Summary collapse
-
#==(other) ⇒ True, False
Compare two OOXMLCoordinates objects.
-
#initialize(x, y) ⇒ OOXMLCoordinates
constructor
A new instance of OOXMLCoordinates.
- #to_s ⇒ Object
Constructor Details
#initialize(x, y) ⇒ OOXMLCoordinates
Returns a new instance of OOXMLCoordinates.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb', line 6 def initialize(x, y) @x = if x.is_a?(OoxmlSize) x else OoxmlSize.new(x) end @y = if y.is_a?(OoxmlSize) y else OoxmlSize.new(y) end end |
Instance Attribute Details
#x ⇒ Object
Returns the value of attribute x.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb', line 4 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb', line 4 def y @y end |
Class Method Details
.parse(position_node, x_attr: 'x', y_attr: 'y', unit: :dxa) ⇒ OOXMLCoordinates
Parse OOXMLCoordinates object
36 37 38 39 40 |
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb', line 36 def self.parse(position_node, x_attr: 'x', y_attr: 'y', unit: :dxa) return if position_node.attribute(x_attr).nil? || position_node.attribute(y_attr).nil? OOXMLCoordinates.new(OoxmlSize.new(position_node.attribute(x_attr).value.to_f, unit), OoxmlSize.new(position_node.attribute(y_attr).value.to_f, unit)) end |
Instance Method Details
#==(other) ⇒ True, False
Compare two OOXMLCoordinates objects
26 27 28 |
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb', line 26 def ==(other) x == other.x && y == other.y end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb', line 19 def to_s '(' + @x.to_s + '; ' + @y.to_s + ')' end |