Class: OoxmlParser::Borders
- Inherits:
-
ParagraphBorders
- Object
- OOXMLDocumentObject
- ParagraphBorders
- OoxmlParser::Borders
- Defined in:
- lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb
Instance Attribute Summary collapse
-
#bar ⇒ Object
Returns the value of attribute bar.
-
#between ⇒ Object
Returns the value of attribute between.
-
#bottom ⇒ Object
Returns the value of attribute bottom.
-
#display ⇒ Object
Returns the value of attribute display.
-
#inner_horizontal ⇒ Object
Returns the value of attribute inner_horizontal.
-
#inner_vertical ⇒ Object
Returns the value of attribute inner_vertical.
-
#left ⇒ Object
Returns the value of attribute left.
-
#offset_from ⇒ Object
Returns the value of attribute offset_from.
-
#right ⇒ Object
Returns the value of attribute right.
-
#top ⇒ Object
Returns the value of attribute top.
-
#top_left_to_bottom_right ⇒ Object
Returns the value of attribute top_left_to_bottom_right.
-
#top_right_to_bottom_left ⇒ Object
Returns the value of attribute top_right_to_bottom_left.
Attributes inherited from OOXMLDocumentObject
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #copy ⇒ Object
- #each_border {|bottom| ... } ⇒ Object
- #each_side {|bottom| ... } ⇒ Object
-
#initialize(left = BordersProperties.new, right = BordersProperties.new, top = BordersProperties.new, bottom = BordersProperties.new, between = BordersProperties.new, parent: nil) ⇒ Borders
constructor
A new instance of Borders.
-
#parse(node) ⇒ Borders
Parse Borders object.
- #to_s ⇒ Object
- #visible? ⇒ Boolean
Methods inherited from ParagraphBorders
Methods inherited from OOXMLDocumentObject
add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, unzip_file, #with_data?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
#initialize(left = BordersProperties.new, right = BordersProperties.new, top = BordersProperties.new, bottom = BordersProperties.new, between = BordersProperties.new, parent: nil) ⇒ Borders
Returns a new instance of Borders.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 7 def initialize(left = BordersProperties.new, right = BordersProperties.new, top = BordersProperties.new, bottom = BordersProperties.new, between = BordersProperties.new, parent: nil) @left = left @right = right @top = top @bottom = bottom @between = between @parent = parent end |
Instance Attribute Details
#bar ⇒ Object
Returns the value of attribute bar.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 4 def end |
#between ⇒ Object
Returns the value of attribute between.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 4 def between @between end |
#bottom ⇒ Object
Returns the value of attribute bottom.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 4 def bottom @bottom end |
#display ⇒ Object
Returns the value of attribute display.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 4 def display @display end |
#inner_horizontal ⇒ Object
Returns the value of attribute inner_horizontal.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 4 def inner_horizontal @inner_horizontal end |
#inner_vertical ⇒ Object
Returns the value of attribute inner_vertical.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 4 def inner_vertical @inner_vertical end |
#left ⇒ Object
Returns the value of attribute left.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 4 def left @left end |
#offset_from ⇒ Object
Returns the value of attribute offset_from.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 4 def offset_from @offset_from end |
#right ⇒ Object
Returns the value of attribute right.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 4 def right @right end |
#top ⇒ Object
Returns the value of attribute top.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 4 def top @top end |
#top_left_to_bottom_right ⇒ Object
Returns the value of attribute top_left_to_bottom_right.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 4 def top_left_to_bottom_right @top_left_to_bottom_right end |
#top_right_to_bottom_left ⇒ Object
Returns the value of attribute top_right_to_bottom_left.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 4 def top_right_to_bottom_left @top_right_to_bottom_left end |
Class Method Details
.parse_from_style(style_number) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 90 def self.parse_from_style(style_number) node = XLSXWorkbook.styles_node.xpath('//xmlns:border')[style_number.to_i] cell_borders = Borders.new node.xpath('*').each do |node_child| case node_child.name when 'bottom' cell_borders.bottom = Border.new(parent: cell_borders).parse(node_child) when 'top' cell_borders.top = Border.new(parent: cell_borders).parse(node_child) when 'right' cell_borders.right = Border.new(parent: cell_borders).parse(node_child) when 'left' cell_borders.left = Border.new(parent: cell_borders).parse(node_child) end end cell_borders end |
Instance Method Details
#==(other) ⇒ Object
31 32 33 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 31 def ==(other) @left == other.left && @right == other.right && @top == other.top && @bottom == other.bottom if other.is_a?(Borders) end |
#copy ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 21 def copy new_borders = Borders.new(@left, @right, @top, @bottom) new_borders.inner_vertical = @inner_vertical unless @inner_vertical.nil? new_borders.inner_horizontal = @inner_horizontal unless @inner_horizontal.nil? new_borders.between = @between unless @between.nil? new_borders.display = @display unless @display.nil? new_borders. = unless .nil? new_borders end |
#each_border {|bottom| ... } ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 35 def each_border yield(bottom) yield(inner_horizontal) yield(inner_vertical) yield(left) yield(right) yield(top) end |
#each_side {|bottom| ... } ⇒ Object
44 45 46 47 48 49 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 44 def each_side yield(bottom) yield(left) yield(right) yield(top) end |
#parse(node) ⇒ Borders
Parse Borders object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 66 def parse(node) node.xpath('*').each do |node_child| case node_child.name when 'lnL', 'left' @left = TableCellLine.new(parent: self).parse(node_child) when 'lnR', 'right' @right = TableCellLine.new(parent: self).parse(node_child) when 'lnT', 'top' @top = TableCellLine.new(parent: self).parse(node_child) when 'lnB', 'bottom' @bottom = TableCellLine.new(parent: self).parse(node_child) when 'lnTlToBr', 'tl2br' @top_left_to_bottom_right = TableCellLine.new(parent: self).parse(node_child) when 'lnBlToTr', 'tr2bl' @top_right_to_bottom_left = TableCellLine.new(parent: self).parse(node_child) when 'insideV' @inner_vertical = TableCellLine.new(parent: self).parse(node_child) when 'insideH' @inner_horizontal = TableCellLine.new(parent: self).parse(node_child) end end self end |
#to_s ⇒ Object
51 52 53 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 51 def to_s "Left border: #{left}, Right: #{right}, Top: #{top}, Bottom: #{bottom}" end |
#visible? ⇒ Boolean
55 56 57 58 59 60 61 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 55 def visible? visible = false each_side do |current_size| visible ||= current_size.visible? end visible end |