Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/rtkit/ruby_extensions.rb

Instance Method Summary collapse

Instance Method Details

#to_coordinateObject

Converts a string (containing a ‘' separated x,y,z coordinate triplet) to a Coordinate instance.

Raises:

  • (ArgumentError)


159
160
161
162
163
# File 'lib/rtkit/ruby_extensions.rb', line 159

def to_coordinate
  values = self.split("\\").collect {|str| str.to_f}
  raise ArgumentError, "Unable to create coordinate. Expected a string containing 3 values, got #{values.length}" unless values.length >= 3
  return RTKIT::Coordinate.new(values[0], values[1], values[2])
end