Class: Gradient::Map

Inherits:
Object
  • Object
show all
Defined in:
lib/gradient/map.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(color_points = [], opacity_points = []) ⇒ Map

Returns a new instance of Map.



6
7
8
9
10
11
12
# File 'lib/gradient/map.rb', line 6

def initialize(color_points=[], opacity_points=[])
  @color_points = sort_points(Array(color_points))
  @opacity_points = sort_points(Array(opacity_points))
  @all_points = sort_points(@color_points + @opacity_points)
  @locations = @all_points.map { |point| point.location }.uniq
  @points ||= expand_points
end

Instance Attribute Details

#color_pointsObject (readonly)

Returns the value of attribute color_points.



4
5
6
# File 'lib/gradient/map.rb', line 4

def color_points
  @color_points
end

#opacity_pointsObject (readonly)

Returns the value of attribute opacity_points.



4
5
6
# File 'lib/gradient/map.rb', line 4

def opacity_points
  @opacity_points
end

#pointsObject (readonly)

Returns the value of attribute points.



4
5
6
# File 'lib/gradient/map.rb', line 4

def points
  @points
end

Instance Method Details

#inspectObject



14
15
16
# File 'lib/gradient/map.rb', line 14

def inspect
  "#<Gradient Map #{points.map(&:inspect).join(" ")}>"
end

#to_css(**args) ⇒ Object



18
19
20
21
# File 'lib/gradient/map.rb', line 18

def to_css(**args)
  @css_printer ||= Gradient::CSSPrinter.new(self)
  @css_printer.css(**args)
end