Class: Plushie::Type::Shadow::Spec

Inherits:
Data
  • Object
show all
Defined in:
lib/plushie/type/shadow.rb

Overview

Immutable spec; use #with to create modified copies.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(color: "#000000", offset_x: 0, offset_y: 0, blur_radius: 0) ⇒ Spec

Returns a new instance of Spec.



23
24
25
# File 'lib/plushie/type/shadow.rb', line 23

def initialize(color: "#000000", offset_x: 0, offset_y: 0, blur_radius: 0)
  super
end

Instance Attribute Details

#blur_radiusObject (readonly)

Returns the value of attribute blur_radius

Returns:

  • (Object)

    the current value of blur_radius



22
23
24
# File 'lib/plushie/type/shadow.rb', line 22

def blur_radius
  @blur_radius
end

#colorObject (readonly)

Returns the value of attribute color

Returns:

  • (Object)

    the current value of color



22
23
24
# File 'lib/plushie/type/shadow.rb', line 22

def color
  @color
end

#offset_xObject (readonly)

Returns the value of attribute offset_x

Returns:

  • (Object)

    the current value of offset_x



22
23
24
# File 'lib/plushie/type/shadow.rb', line 22

def offset_x
  @offset_x
end

#offset_yObject (readonly)

Returns the value of attribute offset_y

Returns:

  • (Object)

    the current value of offset_y



22
23
24
# File 'lib/plushie/type/shadow.rb', line 22

def offset_y
  @offset_y
end

Instance Method Details

#to_wireHash

Returns wire-ready map.

Returns:

  • (Hash)

    wire-ready map



33
34
35
# File 'lib/plushie/type/shadow.rb', line 33

def to_wire
  {color: color, offset: [offset_x, offset_y], blur_radius: blur_radius}
end

#with(**changes) ⇒ Object

Returns a copy with the given fields updated.



28
29
30
# File 'lib/plushie/type/shadow.rb', line 28

def with(**changes)
  self.class.new(**to_h.merge(changes))
end