Class: OoxmlParser::TableMargins
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::TableMargins
- Defined in:
- lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb
Overview
Class for working with Table Margins
Direct Known Subclasses
Instance Attribute Summary collapse
-
#bottom ⇒ Object
Returns the value of attribute bottom.
-
#is_default ⇒ Object
Returns the value of attribute is_default.
-
#left ⇒ Object
Returns the value of attribute left.
-
#right ⇒ Object
Returns the value of attribute right.
-
#top ⇒ Object
Returns the value of attribute top.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#==(other) ⇒ True, False
TODO: Separate @is_default attribute and remove this method Compare this object to other.
-
#initialize(is_default = true, top = nil, bottom = nil, left = nil, right = nil, parent: nil) ⇒ TableMargins
constructor
A new instance of TableMargins.
-
#parse(margin_node) ⇒ TableMargins
Parse TableMargins 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(is_default = true, top = nil, bottom = nil, left = nil, right = nil, parent: nil) ⇒ TableMargins
Returns a new instance of TableMargins.
8 9 10 11 12 13 14 15 |
# 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 |
Instance Attribute Details
#bottom ⇒ Object
Returns the value of attribute bottom.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb', line 6 def bottom @bottom end |
#is_default ⇒ Object
Returns the value of attribute is_default.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb', line 6 def is_default @is_default end |
#left ⇒ Object
Returns the value of attribute left.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb', line 6 def left @left end |
#right ⇒ Object
Returns the value of attribute right.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb', line 6 def right @right end |
#top ⇒ Object
Returns the value of attribute top.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb', line 6 def top @top end |
Instance Method Details
#==(other) ⇒ True, False
TODO: Separate @is_default attribute and remove this method Compare this object to other
21 22 23 24 25 26 27 28 |
# 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) ⇒ TableMargins
Parse TableMargins object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# 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 ⇒ String
Returns result of convert of object to string.
31 32 33 |
# 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 |