Class: Array

Inherits:
Object show all
Defined in:
lib/shattered_ogrerb/vector.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#shuffleObject

Randomize the order of an array

[1, 2, 3].shuffle #=> [2, 3, 1]


58
59
60
# File 'lib/shattered_ogrerb/vector.rb', line 58

def shuffle
  sort_by {rand}
end

#to_vObject

Create a vector from an array.

[1, 2, 3].to_v #=> same as Vector.new(1, 2, 3)

Raises:

  • (StandardError)


66
67
68
69
# File 'lib/shattered_ogrerb/vector.rb', line 66

def to_v
  raise StandardError, "vector #{self.inspect} does not have 3 elements" if self.length < 3
  Ogre::Vector3.new self[0], self[1] ,self[2]
end