Class: Laser::Cutter::Geometry::Shape

Inherits:
Object
  • Object
show all
Defined in:
lib/laser-cutter/geometry/shape.rb

Direct Known Subclasses

Line

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/laser-cutter/geometry/shape.rb', line 5

def name
  @name
end

#positionObject

Returns the value of attribute position.



5
6
7
# File 'lib/laser-cutter/geometry/shape.rb', line 5

def position
  @position
end

Instance Method Details

#move_to(new_point) ⇒ Object



25
26
27
28
29
# File 'lib/laser-cutter/geometry/shape.rb', line 25

def move_to new_point
  self.position = new_point
  relocate!
  self
end

#relocate!Object

Implement in each shape to move to the new pointd



33
34
35
# File 'lib/laser-cutter/geometry/shape.rb', line 33

def relocate!
  raise 'Abstract method'
end

#xObject



14
15
16
# File 'lib/laser-cutter/geometry/shape.rb', line 14

def x
  position.x
end

#x=(value) ⇒ Object



11
12
13
# File 'lib/laser-cutter/geometry/shape.rb', line 11

def x= value
  position.x = value
end

#yObject



21
22
23
# File 'lib/laser-cutter/geometry/shape.rb', line 21

def y
  position.y
end

#y=(value) ⇒ Object



18
19
20
# File 'lib/laser-cutter/geometry/shape.rb', line 18

def y= value
  position.y = value
end