Class: Laser::Cutter::Geometry::Point

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

Constant Summary

Constants inherited from Tuple

Tuple::PRECISION

Instance Attribute Summary

Attributes inherited from Tuple

#coords

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Tuple

#clone, #eql?, #initialize, #to_a, #to_s, #valid?

Constructor Details

This class inherits a constructor from Laser::Cutter::Geometry::Tuple

Class Method Details

.[](*array) ⇒ Object



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

def self.[] *array
  Point.new *array
end

Instance Method Details

#<(other) ⇒ Object



48
49
50
# File 'lib/laser-cutter/geometry/point.rb', line 48

def < (other)
  self.x == other.x ? self.y < other.y : self.x < other.x
end

#<=>(other) ⇒ Object



44
45
46
# File 'lib/laser-cutter/geometry/point.rb', line 44

def <=>(other)
  self.x == other.x ? self.y <=> other.y : self.x <=> other.x
end

#>(other) ⇒ Object



51
52
53
# File 'lib/laser-cutter/geometry/point.rb', line 51

def > (other)
  self.x == other.x ? self.y > other.y : self.x > other.x
end

#customize_args(args) ⇒ Object



9
10
11
12
13
14
# File 'lib/laser-cutter/geometry/point.rb', line 9

def customize_args(args)
  if args.first.is_a?(Point)
    return args.first.to_a
  end
  args
end

#hash_keysObject



36
37
38
# File 'lib/laser-cutter/geometry/point.rb', line 36

def hash_keys
  [:x, :y]
end

#move_by(w, h) ⇒ Object



40
41
42
# File 'lib/laser-cutter/geometry/point.rb', line 40

def move_by w, h
  Point.new(x + w, y + h)
end

#separatorObject



32
33
34
# File 'lib/laser-cutter/geometry/point.rb', line 32

def separator
  ','
end

#xObject



20
21
22
# File 'lib/laser-cutter/geometry/point.rb', line 20

def x
  coords[0]
end

#x=(value) ⇒ Object



16
17
18
# File 'lib/laser-cutter/geometry/point.rb', line 16

def x= value
  coords[0] = value
end

#yObject



28
29
30
# File 'lib/laser-cutter/geometry/point.rb', line 28

def y
  coords[1]
end

#y=(value) ⇒ Object



24
25
26
# File 'lib/laser-cutter/geometry/point.rb', line 24

def y= value
  coords[1] = value
end