class OoxmlParser::TableMargins

Class for working with Table Margins

Attributes

bottom[RW]
is_default[RW]
left[RW]
right[RW]
top[RW]

Public Class Methods

new(is_default = true, top = nil, bottom = nil, left = nil, right = nil, parent: nil) click to toggle source
Calls superclass method OoxmlParser::OOXMLDocumentObject::new
# File lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb, line 8
def initialize(is_default = true, top = nil, bottom = nil, left = nil, right = nil, parent: nil)
  @is_default = is_default
  @top = top
  @bottom = bottom
  @left = left
  @right = right
  super(parent: parent)
end

Public Instance Methods

==(other) click to toggle source

TODO: Separate @is_default attribute and remove this method Compare this object to other @param other [Object] any other object @return [True, False] result of comparision

# File lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb, line 21
def ==(other)
  instance_variables.each do |current_attribute|
    next if current_attribute == :@parent
    next if current_attribute == :@is_default
    return false unless instance_variable_get(current_attribute) == other.instance_variable_get(current_attribute)
  end
  true
end
parse(margin_node) click to toggle source

Parse TableMargins object @param margin_node [Nokogiri::XML:Element] node to parse @return [TableMargins] result of parsing

# File lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb, line 38
def parse(margin_node)
  margin_node.xpath('*').each do |cell_margin_node|
    case cell_margin_node.name
    when 'left'
      @left = OoxmlSize.new(parent: self).parse(cell_margin_node)
    when 'top'
      @top = OoxmlSize.new(parent: self).parse(cell_margin_node)
    when 'right'
      @right = OoxmlSize.new(parent: self).parse(cell_margin_node)
    when 'bottom'
      @bottom = OoxmlSize.new(parent: self).parse(cell_margin_node)
    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/table/margins/table_margins.rb, line 31
def to_s
  "Default: #{is_default} top: #{@top}, bottom: #{@bottom}, left: #{@left}, right: #{@right}"
end