Sha256: 0d935ecbeff50f6552a31f552733d73997b4548edf7e94bb1e5be4ecd5145146

Contents?: true

Size: 549 Bytes

Versions: 4

Compression:

Stored size: 549 Bytes

Contents

# frozen_string_literal: true
class Shoes
  class Gradient
    include Common::Inspect
    include Comparable

    def initialize(color1, color2, alpha = Shoes::Color::OPAQUE)
      @color1 = color1
      @color2 = color2
      @alpha = alpha
    end

    attr_reader :alpha, :color1, :color2

    def <=>(other) # arbitrarily compare 1st non-equal color
      return unless other.is_a?(self.class)
      [color1, color2] <=> [other.color1, other.color2]
    end

    private

    def inspect_details
      " #{color1}->#{color2}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shoes-core-4.0.0.pre12 lib/shoes/gradient.rb
shoes-core-4.0.0.pre11 lib/shoes/gradient.rb
shoes-core-4.0.0.pre10 lib/shoes/gradient.rb
shoes-core-4.0.0.pre9 lib/shoes/gradient.rb