Method: Axlsx::Styles#parse_border_options

Defined in:
lib/axlsx/stylesheet/styles.rb

#parse_border_options(options = {}) ⇒ Border|Integer

Examples:

#apply a thick red border to the top and bottom
{ :border => { :style => :thick, :color => "FFFF0000", :edges => [:top, :bottom] }

Returns:



319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# File 'lib/axlsx/stylesheet/styles.rb', line 319

def parse_border_options(options={})
  return unless options[:border]
  b_opts = options[:border]
  if b_opts.is_a?(Hash)
    raise ArgumentError, (ERR_INVALID_BORDER_OPTIONS % b_opts) unless b_opts.keys.include?(:style) && b_opts.keys.include?(:color)
    border = Border.new b_opts
    (b_opts[:edges] || [:left, :right, :top, :bottom]).each do |edge|
      edge_options = options["border_#{edge}".to_sym] || {}
      border_edge = b_opts.merge(edge_options)
      b_options = { :name => edge, :style => border_edge[:style], :color => Color.new(:rgb => border_edge[:color]) }
      border.prs << BorderPr.new(b_options)
    end
    options[:type] == :dxf ? border : borders << border
  elsif b_opts.is_a? Integer
    raise ArgumentError, (ERR_INVALID_BORDER_ID % b_opts) unless b_opts < borders.size
    if options[:type] == :dxf
      borders[b_opts].clone
    else
      border = b_opts
    end
  end
end