diff options
Diffstat (limited to 'lib/camera/wrappers/square_wrapper.rb')
| -rw-r--r-- | lib/camera/wrappers/square_wrapper.rb | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/camera/wrappers/square_wrapper.rb b/lib/camera/wrappers/square_wrapper.rb index 40578e5..2215a30 100644 --- a/lib/camera/wrappers/square_wrapper.rb +++ b/lib/camera/wrappers/square_wrapper.rb @@ -1,9 +1,18 @@ # frozen_string_literal: true module Camera -# Wraps existing variables as well as adding new methods -# so that it can be handled by the Camera Module + # Wraps existing variables as well as adding new methods + # so that it can be handled by the Camera Module module SquareWrapped + # Squares are part of the exception where + # their x and y variables need to be reset + # when wrapped + def self.extended(obj) + obj.instance_exec do + @x = 0 + @y = 0 + end + end # Recalculates real coordiantes # Use after changing variables def redraw @@ -22,7 +31,7 @@ module Camera #Methods for moving the shape def x - @x ||= x1 + @x ||= 0 end def x=(x) @@ -30,7 +39,7 @@ module Camera end def y - @y ||= y1 + @y ||= 0 end def y=(y) |
