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.
16 17 18 19 20 21 22 23 24 |
# File 'lib/triangular/vertex.rb', line 16 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.
14 15 16 |
# File 'lib/triangular/vertex.rb', line 14 def point @point end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object
30 31 32 33 34 |
# File 'lib/triangular/vertex.rb', line 30 def ==(other) return false unless other.is_a?(Vertex) x == other.x && y == other.y && z == other.z end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/triangular/vertex.rb', line 26 def to_s "vertex #{@point}" end |