Class: MD2::Vertex

Inherits:
Array
  • Object
show all
Defined in:
lib/md2/vertex.rb

Instance Method Summary collapse

Constructor Details

#initialize(x, y, z) ⇒ Vertex

Returns a new instance of Vertex.

Raises:

  • (ArgumentError)


2
3
4
5
6
7
8
# File 'lib/md2/vertex.rb', line 2

def initialize(x, y, z)
  super()
  raise ArgumentError, "x is nil" if x.nil?
  raise ArgumentError, "y is nil" if y.nil?
  raise ArgumentError, "z is nil" if z.nil?
  self << x << y << z
end

Instance Method Details

#xObject



10
11
12
# File 'lib/md2/vertex.rb', line 10

def x
  self[0]
end

#x=(x) ⇒ Object



22
23
24
# File 'lib/md2/vertex.rb', line 22

def x=(x)
  self[0] = x
end

#yObject



14
15
16
# File 'lib/md2/vertex.rb', line 14

def y
  self[1]
end

#y=(y) ⇒ Object



26
27
28
# File 'lib/md2/vertex.rb', line 26

def y=(y)
  self[1] = y
end

#zObject



18
19
20
# File 'lib/md2/vertex.rb', line 18

def z
  self[2]
end

#z=(z) ⇒ Object



30
31
32
# File 'lib/md2/vertex.rb', line 30

def z=(z)
  self[2] = z
end