Sha256: 31f8660fc4a0d463321395cd4216c6fb59896ab6a33ed3111be337f36426b3bc

Contents?: true

Size: 1.94 KB

Versions: 17

Compression:

Stored size: 1.94 KB

Contents

# encoding: UTF-8
module Axlsx
  # A PatternFill is the pattern and solid fill styling for a cell.
  # @note The recommended way to manage styles is with Styles#add_style
  # @see Style#add_style
  class PatternFill

    include Axlsx::OptionsParser
    # Creates a new PatternFill Object
    # @option options [Symbol] patternType
    # @option options [Color] fgColor
    # @option options [Color] bgColor
    def initialize(options={})
      @patternType = :none
      parse_options options
    end

    # The color to use for the the background in solid fills.
    # @return [Color]
    attr_reader :fgColor

    # The color to use for the background of the fill when the type is not solid.
    # @return [Color]
    attr_reader :bgColor

    # The pattern type to use
    # @note
    #  patternType must be one of
    #   :none
    #   :solid
    #   :mediumGray
    #   :darkGray
    #   :lightGray
    #   :darkHorizontal
    #   :darkVertical
    #   :darkDown
    #   :darkUp
    #   :darkGrid
    #   :darkTrellis
    #   :lightHorizontal
    #   :lightVertical
    #   :lightDown
    #   :lightUp
    #   :lightGrid
    #   :lightTrellis
    #   :gray125
    #   :gray0625
    # @see Office Open XML Part 1 18.18.55
    attr_reader :patternType

    # @see fgColor
    def fgColor=(v) DataTypeValidator.validate "PatternFill.fgColor", Color, v; @fgColor=v end
    # @see bgColor
    def bgColor=(v) DataTypeValidator.validate "PatternFill.bgColor", Color, v; @bgColor=v end
    # @see patternType
    def patternType=(v) Axlsx::validate_pattern_type v; @patternType = v end

    # Serializes the object
    # @param [String] str
    # @return [String]
    def to_xml_string(str = '')
      str << ('<patternFill patternType="' << patternType.to_s << '">')
      if fgColor.is_a?(Color)
        fgColor.to_xml_string str, "fgColor"
      end

      if bgColor.is_a?(Color)
        bgColor.to_xml_string str, "bgColor"
      end
      str << '</patternFill>'
    end
  end
end

Version data entries

17 entries across 17 versions & 6 rubygems

Version Path
caxlsx-3.3.0 lib/axlsx/stylesheet/pattern_fill.rb
caxlsx-3.1.1 lib/axlsx/stylesheet/pattern_fill.rb
caxlsx-3.1.0 lib/axlsx/stylesheet/pattern_fill.rb
bonio-axlsx-2.2.3 lib/axlsx/stylesheet/pattern_fill.rb
caxlsx-3.0.4 lib/axlsx/stylesheet/pattern_fill.rb
caxlsx-3.0.3 lib/axlsx/stylesheet/pattern_fill.rb
caxlsx-3.0.2 lib/axlsx/stylesheet/pattern_fill.rb
caxlsx-3.0.1 lib/axlsx/stylesheet/pattern_fill.rb
caxlsx-3.0.0 lib/axlsx/stylesheet/pattern_fill.rb
axlsx-alt-3.0.1 lib/axlsx/stylesheet/pattern_fill.rb
axlsx-alt-3.0.0 lib/axlsx/stylesheet/pattern_fill.rb
axlsx-3.0.0.pre lib/axlsx/stylesheet/pattern_fill.rb
bonio-axlsx-2.2.2 lib/axlsx/stylesheet/pattern_fill.rb
bonio-axlsx-2.2.1 lib/axlsx/stylesheet/pattern_fill.rb
dg-axlsx-2.1.0 lib/axlsx/stylesheet/pattern_fill.rb
axlsx-2.1.0.pre lib/axlsx/stylesheet/pattern_fill.rb
l_axlsx-2.0.1 lib/axlsx/stylesheet/pattern_fill.rb