Sha256: 156d652da7d4dd523eab26268035721c34212d5a04a6cd034c5f9b63b71aa5e5
Contents?: true
Size: 743 Bytes
Versions: 1
Compression:
Stored size: 743 Bytes
Contents
class Shoes class Gradient include Common::Inspect include Comparable def initialize(color1, color2, alpha = Shoes::Color::OPAQUE) @color1, @color2 = color1, color2 @alpha = alpha end attr_reader :alpha, :color1, :color2 def inspect super.insert(-2, " #{color1}->#{color2}") end def <=>(other) #arbitrarily compare 1st non-equal color raise_class_mismatch_error(other) unless other.is_a?(self.class) if @color1 == other.color1 @color2 <=> other.color2 else @color1 <=> other.color1 end end def raise_class_mismatch_error other raise ArgumentError, "can't compare #{self.class.name} with #{other.class.name}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shoes-dsl-4.0.0.pre2 | lib/shoes/gradient.rb |