Sha256: 6ffb42e73bb98b5c062af6fe3a5f5b771f1224358d790e81aef4d37729971a1c

Contents?: true

Size: 1.28 KB

Versions: 37

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

require_relative 'fill/pattern_fill'
module OoxmlParser
  # Parsing `fill` tag
  class Fill < OOXMLDocumentObject
    # @return [PatternFill] pattern fill
    attr_accessor :pattern_fill
    # @return [Color] second color
    attr_reader :color2
    # @return [String] id of file
    attr_reader :id
    # @return [FileReference] file of fill
    attr_reader :file
    # @return [Symbol] value
    attr_reader :value

    # Parse Fill data
    # @param [Nokogiri::XML:Element] node with Fill data
    # @return [Fill] value of Fill data
    def parse(node)
      node.attributes.each do |key, value|
        case key
        when 'color2'
          @color2 = Color.new(parent: self).parse_hex_string(value.value.split.first.delete('#'))
        when 'id'
          @id = value.value.to_s
          @file = FileReference.new(parent: self).parse(node)
        when 'type'
          @type = value_to_symbol(value)
        end
      end

      node.xpath('*').each do |node_child|
        case node_child.name
        when 'patternFill'
          @pattern_fill = PatternFill.new(parent: self).parse(node_child)
        end
      end
      self
    end

    # Convert Fill to color
    # @return [OoxmlColor] result
    def to_color
      pattern_fill.foreground_color
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
ooxml_parser-0.37.1 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fills/fill.rb
ooxml_parser-0.37.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fills/fill.rb
ooxml_parser-0.36.1 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fills/fill.rb
ooxml_parser-0.36.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fills/fill.rb
ooxml_parser-0.35.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fills/fill.rb
ooxml_parser-0.34.2 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fills/fill.rb
ooxml_parser-0.34.1 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fills/fill.rb
ooxml_parser-0.34.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fills/fill.rb
ooxml_parser-0.33.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fills/fill.rb
ooxml_parser-0.32.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fills/fill.rb
ooxml_parser-0.31.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fills/fill.rb
ooxml_parser-0.30.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fills/fill.rb
ooxml_parser-0.29.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fills/fill.rb
ooxml_parser-0.28.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fills/fill.rb
ooxml_parser-0.27.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fills/fill.rb
ooxml_parser-0.26.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fills/fill.rb
ooxml_parser-0.25.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fills/fill.rb
ooxml_parser-0.24.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fills/fill.rb
ooxml_parser-0.23.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills/fill.rb
ooxml_parser-0.22.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills/fill.rb