Class: Gradient::Map
- Inherits:
-
Object
- Object
- Gradient::Map
- Defined in:
- lib/gradient/map.rb
Instance Attribute Summary collapse
-
#locations ⇒ Object
readonly
Returns the value of attribute locations.
-
#points ⇒ Object
readonly
Returns the value of attribute points.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json(json = {}) ⇒ Object
-
#initialize(*points) ⇒ Map
constructor
A new instance of Map.
- #inspect ⇒ Object
- #serialize ⇒ Object
- #to_css(**args) ⇒ Object
Constructor Details
#initialize(*points) ⇒ Map
Returns a new instance of Map.
12 13 14 15 |
# File 'lib/gradient/map.rb', line 12 def initialize(*points) @points = points.flatten.sort @locations = @points.map { |point| point.location } end |
Instance Attribute Details
#locations ⇒ Object (readonly)
Returns the value of attribute locations.
4 5 6 |
# File 'lib/gradient/map.rb', line 4 def locations @locations end |
#points ⇒ Object (readonly)
Returns the value of attribute points.
4 5 6 |
# File 'lib/gradient/map.rb', line 4 def points @points end |
Class Method Details
.deserialize(points = []) ⇒ Object
7 8 9 |
# File 'lib/gradient/map.rb', line 7 def deserialize(points=[]) new(points.map { |point| Gradient::Point.deserialize(*point) }) end |
Instance Method Details
#as_json(json = {}) ⇒ Object
30 31 32 |
# File 'lib/gradient/map.rb', line 30 def as_json(json={}) serialize end |
#inspect ⇒ Object
17 18 19 |
# File 'lib/gradient/map.rb', line 17 def inspect "#<Gradient Map #{points.map(&:inspect).join(" ")}>" end |
#serialize ⇒ Object
26 27 28 |
# File 'lib/gradient/map.rb', line 26 def serialize @points.map(&:serialize) end |
#to_css(**args) ⇒ Object
21 22 23 24 |
# File 'lib/gradient/map.rb', line 21 def to_css(**args) @css_printer ||= Gradient::CSSPrinter.new(self) @css_printer.css(**args) end |