Sha256: e6a24a47687df446ed3b4ff45d03e5aedf900ada0f875247cf272891f47376c1

Contents?: true

Size: 1.2 KB

Versions: 6

Compression:

Stored size: 1.2 KB

Contents

module Axlsx
  # Conditional Format Rule color scale object
  # Describes a gradated color scale in this conditional formatting rule.

  # @note The recommended way to manage these rules is via Worksheet#add_conditional_formatting
  # @see Worksheet#add_conditional_formatting
  # @see ConditionalFormattingRule#initialize
  class ColorScale

    # A simple typed list of cfvos
    # @return [SimpleTypedList]
    # @see cfvo
    attr_reader :cfvos

    # A simple types list of colors
    # @return [SimpleTypedList]
    # @see Color
    attr_reader :colors

    def initializer
      initialize_cfvos
      initialize_colors
      yield self if block_given?
    end

    def add
      @cfvos << Cfvo.new(:type => :min, :val => 0)
      @colors << Color.new :rgb => "FF000000"
      {:cfvo => @cfvos.last, :color => @colors.last}
    end

    protected

    def initialize_cfvos
      @cfvos = SimpleTypedList.new Cfvo
      @cfvos.concat [Cfvo.new(:type => :min, :val => 0), Cfvo.new(:type => :max, :val => 0)]
      @cfvos.lock
    end

    def initialize_colors
      @colors = SimpleTypedList.new Color
      @colors.concat [Color.new(:rgb => "FFFF0000", Color.new(:rgb => "FF0000FF")]
      @colors.lock
    end

  end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
axlsx-1.1.7 lib/axlsx/workbook/worksheet/color_scale.rb~
axlsx-1.1.6 lib/axlsx/workbook/worksheet/color_scale.rb~
axlsx-1.1.5 lib/axlsx/workbook/worksheet/color_scale.rb~
axlsx-1.1.4 lib/axlsx/workbook/worksheet/color_scale.rb~
axlsx-1.1.3 lib/axlsx/workbook/worksheet/color_scale.rb~
axlsx-1.1.2 lib/axlsx/workbook/worksheet/color_scale.rb~