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.



124
125
126
# File 'lib/ooxml_excel/styles.rb', line 124

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

Instance Attribute Details

#bg_colorObject

Returns the value of attribute bg_color.



122
123
124
# File 'lib/ooxml_excel/styles.rb', line 122

def bg_color
  @bg_color
end

#bg_color_indexObject

Returns the value of attribute bg_color_index.



122
123
124
# File 'lib/ooxml_excel/styles.rb', line 122

def bg_color_index
  @bg_color_index
end

#fg_colorObject

Returns the value of attribute fg_color.



122
123
124
# File 'lib/ooxml_excel/styles.rb', line 122

def fg_color
  @fg_color
end

#fg_color_indexObject

Returns the value of attribute fg_color_index.



122
123
124
# File 'lib/ooxml_excel/styles.rb', line 122

def fg_color_index
  @fg_color_index
end

#fg_color_themeObject

Returns the value of attribute fg_color_theme.



122
123
124
# File 'lib/ooxml_excel/styles.rb', line 122

def fg_color_theme
  @fg_color_theme
end

#fg_color_tintObject

Returns the value of attribute fg_color_tint.



122
123
124
# File 'lib/ooxml_excel/styles.rb', line 122

def fg_color_tint
  @fg_color_tint
end

#pattern_typeObject

Returns the value of attribute pattern_type.



122
123
124
# File 'lib/ooxml_excel/styles.rb', line 122

def pattern_type
  @pattern_type
end

Class Method Details

.load_from_node(fill_node) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/ooxml_excel/styles.rb', line 127

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')
    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