Class: Triangular::Vertex
- Inherits:
-
Object
- Object
- Triangular::Vertex
- Extended by:
- Forwardable
- Defined in:
- lib/triangular/vertex.rb
Instance Attribute Summary collapse
-
#point ⇒ Object
Returns the value of attribute point.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(*args) ⇒ Vertex
constructor
A new instance of Vertex.
- #to_s ⇒ Object
Constructor Details
#initialize(*args) ⇒ Vertex
Returns a new instance of Vertex.
14 15 16 17 18 19 20 21 22 |
# File 'lib/triangular/vertex.rb', line 14 def initialize(*args) if args.length == 1 && args.first.is_a?(Point) @point = args.first elsif args.length == 3 @point = Point.new(args[0], args[1], args[2]) else raise "You must either supply the XYZ coordinates or a Point object to create a Vertex" end end |
Instance Attribute Details
#point ⇒ Object
Returns the value of attribute point.
12 13 14 |
# File 'lib/triangular/vertex.rb', line 12 def point @point end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object
28 29 30 31 |
# File 'lib/triangular/vertex.rb', line 28 def ==(other) return false unless other.is_a?(Vertex) self.x == other.x && self.y == other.y && self.z == other.z end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/triangular/vertex.rb', line 24 def to_s "vertex #{@point.to_s}" end |