Class: OOXML::Excel::Styles::Fill

Inherits:
Object
  • Object
show all
Defined in:
lib/ooxml_excel/styles.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**attrs) ⇒ Fill

Returns a new instance of Fill.



104
105
106
# File 'lib/ooxml_excel/styles.rb', line 104

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

Instance Attribute Details

#bg_colorObject

Returns the value of attribute bg_color.



102
103
104
# File 'lib/ooxml_excel/styles.rb', line 102

def bg_color
  @bg_color
end

#bg_color_indexObject

Returns the value of attribute bg_color_index.



102
103
104
# File 'lib/ooxml_excel/styles.rb', line 102

def bg_color_index
  @bg_color_index
end

#fg_colorObject

Returns the value of attribute fg_color.



102
103
104
# File 'lib/ooxml_excel/styles.rb', line 102

def fg_color
  @fg_color
end

#fg_color_themeObject

Returns the value of attribute fg_color_theme.



102
103
104
# File 'lib/ooxml_excel/styles.rb', line 102

def fg_color_theme
  @fg_color_theme
end

#fg_color_tintObject

Returns the value of attribute fg_color_tint.



102
103
104
# File 'lib/ooxml_excel/styles.rb', line 102

def fg_color_tint
  @fg_color_tint
end

#pattern_typeObject

Returns the value of attribute pattern_type.



102
103
104
# File 'lib/ooxml_excel/styles.rb', line 102

def pattern_type
  @pattern_type
end

Class Method Details

.load_from_node(fill_node) ⇒ Object



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/ooxml_excel/styles.rb', line 107

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

  pattern_type = pattern_fill.attributes["patternType"].value
  if pattern_type == "solid"
    fg_color = pattern_fill.at('fgColor')
    bg_color = pattern_fill.at('bgColor')
    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)
  else
    self.new(pattern_type: pattern_type)
  end
end