Class: Laser::Cutter::Geometry::Shape
- Inherits:
-
Object
- Object
- Laser::Cutter::Geometry::Shape
- Defined in:
- lib/laser/cutter/geometry/shape.rb
Overview
The base of a shape that sits at a position and can be moved there.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ String, ...
The name of the shape, such as the face of a box.
-
#position ⇒ Point
Where the shape sits, the origin until set.
Instance Method Summary collapse
-
#move_to(new_point) ⇒ Shape
Moves the shape so that its position is the point.
-
#relocate! ⇒ void
Moves the shape's own coordinates to its position.
-
#x ⇒ Float
The x of the position.
-
#x=(value) ⇒ Float
The value.
-
#y ⇒ Float
The y of the position.
-
#y=(value) ⇒ Float
The value.
Instance Attribute Details
#name ⇒ String, ...
Returns the name of the shape, such as the face of a box.
10 |
# File 'lib/laser/cutter/geometry/shape.rb', line 10 attr_accessor :position, :name |
#position ⇒ Point
Returns where the shape sits, the origin until set.
10 11 12 |
# File 'lib/laser/cutter/geometry/shape.rb', line 10 def position @position end |
Instance Method Details
#move_to(new_point) ⇒ Shape
Moves the shape so that its position is the point.
43 44 45 46 47 |
# File 'lib/laser/cutter/geometry/shape.rb', line 43 def move_to(new_point) self.position = new_point relocate! self end |
#relocate! ⇒ void
This method returns an undefined value.
Moves the shape's own coordinates to its position. Each shape implements it.
54 55 56 |
# File 'lib/laser/cutter/geometry/shape.rb', line 54 def relocate! raise 'Abstract method' end |
#x ⇒ Float
Returns the x of the position.
24 25 26 |
# File 'lib/laser/cutter/geometry/shape.rb', line 24 def x position.x end |
#x=(value) ⇒ Float
Returns the value.
19 20 21 |
# File 'lib/laser/cutter/geometry/shape.rb', line 19 def x=(value) position.x = value end |
#y ⇒ Float
Returns the y of the position.
35 36 37 |
# File 'lib/laser/cutter/geometry/shape.rb', line 35 def y position.y end |
#y=(value) ⇒ Float
Returns the value.
30 31 32 |
# File 'lib/laser/cutter/geometry/shape.rb', line 30 def y=(value) position.y = value end |