class Gradient::Point
Attributes
color[R]
location[R]
opacity[R]
Public Class Methods
deserialize(location, color_type, color_values, opacity)
click to toggle source
# File lib/gradient/point.rb, line 7 def deserialize(location, color_type, color_values, opacity) self.new(location, color_from(color_type, color_values), opacity) end
new(location, color, opacity)
click to toggle source
# File lib/gradient/point.rb, line 20 def initialize(location, color, opacity) @location, @color, @opacity = location, color, opacity end
Private Class Methods
color_from(color_type, color_values)
click to toggle source
# File lib/gradient/point.rb, line 11 def color_from(color_type, color_values) case color_type when "rgb" then Color::RGB.new(*color_values) else raise NotImplementedError.new("#{string} is not a valid color type") end end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/gradient/point.rb, line 28 def <=>(other) self.location <=> other.location end
==(other)
click to toggle source
# File lib/gradient/point.rb, line 40 def ==(other) unless other.kind_of?(Gradient::Point) raise ArgumentError.new("cannot compare Point with #{ other.class } using `=='") end location == other.location && color == other.color && opacity == other.opacity end
as_json(json={})
click to toggle source
# File lib/gradient/point.rb, line 36 def as_json(json={}) serialize end
inspect()
click to toggle source
# File lib/gradient/point.rb, line 24 def inspect "#<Point #{location * 100} ##{color.hex}#{"%02x" % (opacity * 255).round}>" end
serialize()
click to toggle source
# File lib/gradient/point.rb, line 32 def serialize [location, "rgb", [color.red.round, color.green.round, color.blue.round], opacity] end