Class: Plushie::Canvas::Shape::DragBounds

Inherits:
Data
  • Object
show all
Defined in:
lib/plushie/canvas/shape/drag_bounds.rb

Overview

Drag constraint bounds for interactive canvas shapes.

Examples:

DragBounds.new(min_x: 0, max_x: 400, min_y: 0, max_y: 300)
DragBounds.new(min_x: 0, max_x: 100)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(min_x: nil, max_x: nil, min_y: nil, max_y: nil) ⇒ DragBounds

Returns a new instance of DragBounds.



12
13
14
# File 'lib/plushie/canvas/shape/drag_bounds.rb', line 12

def initialize(min_x: nil, max_x: nil, min_y: nil, max_y: nil)
  super
end

Instance Attribute Details

#max_xObject (readonly)

Returns the value of attribute max_x

Returns:

  • (Object)

    the current value of max_x



11
12
13
# File 'lib/plushie/canvas/shape/drag_bounds.rb', line 11

def max_x
  @max_x
end

#max_yObject (readonly)

Returns the value of attribute max_y

Returns:

  • (Object)

    the current value of max_y



11
12
13
# File 'lib/plushie/canvas/shape/drag_bounds.rb', line 11

def max_y
  @max_y
end

#min_xObject (readonly)

Returns the value of attribute min_x

Returns:

  • (Object)

    the current value of min_x



11
12
13
# File 'lib/plushie/canvas/shape/drag_bounds.rb', line 11

def min_x
  @min_x
end

#min_yObject (readonly)

Returns the value of attribute min_y

Returns:

  • (Object)

    the current value of min_y



11
12
13
# File 'lib/plushie/canvas/shape/drag_bounds.rb', line 11

def min_y
  @min_y
end

Instance Method Details

#[](key) ⇒ Object

Backward-compatible hash-style access.



17
# File 'lib/plushie/canvas/shape/drag_bounds.rb', line 17

def [](key) = to_wire[key]

#to_wireHash

Returns wire-ready bounds map (nil fields stripped).

Returns:

  • (Hash)

    wire-ready bounds map (nil fields stripped)



20
21
22
23
24
25
26
27
# File 'lib/plushie/canvas/shape/drag_bounds.rb', line 20

def to_wire
  h = {}
  h[:min_x] = min_x if min_x
  h[:max_x] = max_x if max_x
  h[:min_y] = min_y if min_y
  h[:max_y] = max_y if max_y
  h
end