Class: String

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

Instance Method Summary collapse

Instance Method Details

#to_rObject



164
165
166
167
168
169
170
171
# File 'lib/kgl/kmath.rb', line 164

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