class OoxmlParser::OOXMLCoordinates

Docx Coordinates

Attributes

x[RW]
y[RW]

Public Class Methods

new(x_value = nil, y_value = nil, parent: nil) click to toggle source
Calls superclass method
# 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

Public Instance Methods

==(other) click to toggle source

Compare two OOXMLCoordinates objects @param other [OOXMLCoordinates] other object @return [True, False] result of comparison

# 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) click to toggle source

Parse OOXMLCoordinates object @param node [Nokogiri::XML:Element] node to parse @param x_attr [String] name of x attribute @param y_attr [String] name of y attribute @param unit [Symbol] unit in which data is stored @return [OOXMLCoordinates] result of parsing

# 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() click to toggle source

@return [String] result of convert of object to string

# File lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb, line 23
def to_s
  "(#{@x}; #{@y})"
end