Sha256: a47b90146607db5b3970e596727fb68145c5b0e377dd5484a7c7afdbe9d70d18

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module Axlsx
  # The GradientStop object represents a color point in a gradient.
  # @see Open Office XML Part 1 ยง18.8.24
  class GradientStop
    # The color for this gradient stop
    # @return [Color]
    # @see Color
    attr_reader :color

    # The position of the color
    # @return [Float]
    attr_reader :position

    # Creates a new GradientStop object
    # @param [Color] color
    # @param [Float] position
    def initialize(color, position)
      self.color = color
      self.position = position
    end

    # @see color
    def color=(v) DataTypeValidator.validate "GradientStop.color", Color, v; @color = v end
    # @see position
    def position=(v) DataTypeValidator.validate "GradientStop.position", Float, v, ->(arg) { arg >= 0 && arg <= 1 }; @position = v end

    # Serializes the object
    # @param [String] str
    # @return [String]
    def to_xml_string(str = +'')
      str << '<stop position="' << position.to_s << '">'
      color.to_xml_string(str)
      str << '</stop>'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caxlsx-4.0.0 lib/axlsx/stylesheet/gradient_stop.rb