Class: OOXL::Fill

Inherits:
Object
  • Object
show all
Defined in:
lib/ooxl/xl_objects/fill.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**attrs) ⇒ Fill

Returns a new instance of Fill.



5
6
7
# File 'lib/ooxl/xl_objects/fill.rb', line 5

def initialize(**attrs)
  attrs.each { |property, value| send("#{property}=", value)}
end

Instance Attribute Details

#bg_colorObject

Returns the value of attribute bg_color.



3
4
5
# File 'lib/ooxl/xl_objects/fill.rb', line 3

def bg_color
  @bg_color
end

#bg_color_indexObject

Returns the value of attribute bg_color_index.



3
4
5
# File 'lib/ooxl/xl_objects/fill.rb', line 3

def bg_color_index
  @bg_color_index
end

#fg_colorObject

Returns the value of attribute fg_color.



3
4
5
# File 'lib/ooxl/xl_objects/fill.rb', line 3

def fg_color
  @fg_color
end

#fg_color_indexObject

Returns the value of attribute fg_color_index.



3
4
5
# File 'lib/ooxl/xl_objects/fill.rb', line 3

def fg_color_index
  @fg_color_index
end

#fg_color_themeObject

Returns the value of attribute fg_color_theme.



3
4
5
# File 'lib/ooxl/xl_objects/fill.rb', line 3

def fg_color_theme
  @fg_color_theme
end

#fg_color_tintObject

Returns the value of attribute fg_color_tint.



3
4
5
# File 'lib/ooxl/xl_objects/fill.rb', line 3

def fg_color_tint
  @fg_color_tint
end

#pattern_typeObject

Returns the value of attribute pattern_type.



3
4
5
# File 'lib/ooxl/xl_objects/fill.rb', line 3

def pattern_type
  @pattern_type
end

Class Method Details

.load_from_node(fill_node) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ooxl/xl_objects/fill.rb', line 8

def self.load_from_node(fill_node)
  pattern_fill = fill_node.at('patternFill')

  pattern_type = pattern_fill.attributes["patternType"].try(:value)
  if pattern_type == "solid"
    fg_color = pattern_fill.at('fgColor')
    bg_color = pattern_fill.at('bgColor')
    fg_color_index = fg_color.class == Nokogiri::XML::Element ? fg_color.attributes["indexed"].try(:value) : nil

    self.new(pattern_type: pattern_type,
            fg_color: (fg_color.present?) ? fg_color.attributes["rgb"].try(:value) : nil,
            fg_color_theme: (fg_color.present?) ? fg_color.attributes["theme"].try(:value) : nil,
            fg_color_tint:  (fg_color.present?) ? fg_color.attributes["tint"].try(:value) : nil,
            bg_color: (bg_color.present?) ?  bg_color.attributes["rgb"].try(:value) : nil,
            bg_color_index: (bg_color.present?) ?  bg_color.attributes["index"].try(:value) : nil,
            fg_color_index: fg_color_index)
  else
    self.new(pattern_type: pattern_type)
  end
end