Class: Array
Overview
:nodoc:
Instance Method Summary collapse
-
#shuffle ⇒ Object
Randomize the order of an array.
-
#to_v ⇒ Object
Create a vector from an array.
Instance Method Details
#shuffle ⇒ Object
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_v ⇒ Object
Create a vector from an array.
[1, 2, 3].to_v #=> same as Vector.new(1, 2, 3)
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 |