Class: Axlsx::BorderCreator
- Inherits:
-
Object
- Object
- Axlsx::BorderCreator
- Defined in:
- lib/axlsx/workbook/worksheet/border_creator.rb
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(worksheet:, cells:, edges: nil, style: nil, color: nil) ⇒ BorderCreator
constructor
A new instance of BorderCreator.
Constructor Details
#initialize(worksheet:, cells:, edges: nil, style: nil, color: nil) ⇒ BorderCreator
Returns a new instance of BorderCreator.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/axlsx/workbook/worksheet/border_creator.rb', line 5 def initialize(worksheet:, cells:, edges: nil, style: nil, color: nil) @worksheet = worksheet @cells = cells @edges = edges || :all @style = style || :thin @color = color || "000000" if @edges == :all @edges = Axlsx::Border::EDGES elsif !@edges.is_a?(Array) raise ArgumentError, "Invalid edges provided, #{@edges}" else @edges = @edges.map { |x| x&.to_sym }.uniq unless (@edges - Axlsx::Border::EDGES).empty? raise ArgumentError, "Invalid edges provided, #{edges}" end end end |
Instance Method Details
#draw ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/axlsx/workbook/worksheet/border_creator.rb', line 26 def draw if @cells.size == 1 @worksheet.add_style( first_cell, { border: { style: @style, color: @color, edges: @edges } } ) else @edges.each do |edge| @worksheet.add_style( border_cells[edge], { border: { style: @style, color: @color, edges: [edge] } } ) end end end |