Class: OoxmlParser::Borders
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::Borders
- Defined in:
- lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb
Constant Summary
Constants inherited from OOXMLDocumentObject
OOXMLDocumentObject::DEFAULT_DIRECTORY_FOR_MEDIA
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.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #border_visual_type ⇒ 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) ⇒ Borders
constructor
A new instance of Borders.
- #to_s ⇒ Object
- #visible? ⇒ Boolean
Methods inherited from OOXMLDocumentObject
add_to_xmls_stack, copy_file_and_rename_to_zip, copy_media_file, current_xml, dir, encrypted_file?, get_link_from_rels, media_folder, option_enabled?, unzip_file
Constructor Details
#initialize(left = BordersProperties.new, right = BordersProperties.new, top = BordersProperties.new, bottom = BordersProperties.new, between = BordersProperties.new) ⇒ Borders
Returns a new instance of Borders.
7 8 9 10 11 12 13 14 15 16 17 |
# 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) @left = left @right = right @top = top @bottom = bottom @between = between 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 @bar 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(borders_node) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 74 def self.parse(borders_node) borders = Borders.new borders_node.xpath('*').each do |border_node| case border_node.name when 'lnL', 'left' borders.left = TableCellLine.parse(border_node) when 'lnR', 'right' borders.right = TableCellLine.parse(border_node) when 'lnT', 'top' borders.top = TableCellLine.parse(border_node) when 'lnB', 'bottom' borders.bottom = TableCellLine.parse(border_node) when 'lnTlToBr', 'tl2br' borders.top_left_to_bottom_right = TableCellLine.parse(border_node) when 'lnBlToTr', 'tr2bl' borders.top_right_to_bottom_left = TableCellLine.parse(border_node) when 'insideV' borders.inner_vertical = TableCellLine.parse(border_node) when 'insideH' borders.inner_horizontal = TableCellLine.parse(border_node) end end borders end |
.parse_from_style(style_number) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 99 def self.parse_from_style(style_number) border_style_node = XLSXWorkbook.styles_node.xpath('//xmlns:border')[style_number.to_i] cell_borders = Borders.new unless border_style_node.xpath('xmlns:bottom')[0].attribute('style').nil? cell_borders.bottom = Border.new cell_borders.bottom.style = border_style_node.xpath('xmlns:bottom')[0].attribute('style').value cell_borders.bottom.color = Color.parse_color_tag(border_style_node.xpath('xmlns:bottom/xmlns:color')[0]) end unless border_style_node.xpath('xmlns:top')[0].attribute('style').nil? cell_borders.top = Border.new cell_borders.top.style = border_style_node.xpath('xmlns:top')[0].attribute('style').value cell_borders.top.color = Color.parse_color_tag(border_style_node.xpath('xmlns:top/xmlns:color')[0]) end unless border_style_node.xpath('xmlns:right')[0].attribute('style').nil? cell_borders.right = Border.new cell_borders.right.style = border_style_node.xpath('xmlns:right')[0].attribute('style').value cell_borders.right.color = Color.parse_color_tag(border_style_node.xpath('xmlns:right/xmlns:color')[0]) end unless border_style_node.xpath('xmlns:left')[0].attribute('style').nil? cell_borders.left = Border.new cell_borders.left.style = border_style_node.xpath('xmlns:left')[0].attribute('style').value cell_borders.left.color = Color.parse_color_tag(border_style_node.xpath('xmlns:left/xmlns:color')[0]) end cell_borders end |
Instance Method Details
#==(other) ⇒ Object
29 30 31 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 29 def ==(other) @left == other.left && @right == other.right && @top == other.top && @bottom == other.bottom if other.is_a?(Borders) end |
#border_visual_type ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 49 def border_visual_type result = [] result << :left if @left.val == :single result << :right if @right.val == :single result << :top if @top.val == :single result << :bottom if @bottom.val == :single result << :inner if @between.val == :single return :none if result == [] return :all if result == [:left, :right, :top, :bottom, :inner] return :outer if result == [:left, :right, :top, :bottom] return result.first if result.size == 1 end |
#copy ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 19 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. = @bar unless .nil? new_borders end |
#each_border {|bottom| ... } ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 33 def each_border yield(bottom) yield(inner_horizontal) yield(inner_vertical) yield(left) yield(right) yield(top) end |
#each_side {|bottom| ... } ⇒ Object
42 43 44 45 46 47 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 42 def each_side yield(bottom) yield(left) yield(right) yield(top) end |
#to_s ⇒ Object
62 63 64 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 62 def to_s "Left border: #{left}, Right: #{right}, Top: #{top}, Bottom: #{bottom}" end |
#visible? ⇒ Boolean
66 67 68 69 70 71 72 |
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb', line 66 def visible? visible = false each_side do |current_size| visible ||= current_size.visible? end visible end |