Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/kgl/kmath.rb

Instance Method Summary collapse

Instance Method Details

#to_rObject



174
175
176
177
178
179
180
181
# File 'lib/kgl/kmath.rb', line 174

def to_r
	(numerator, denominator) = self.split(/\//)
	if self.match(/\.|e/)
		return numerator.to_f.to_r / denominator.to_f.to_r
	else
		return Rational(numerator.to_i, denominator.to_i)
	end
end