lib/lisp/interpreter/core/object.rb in lisp-interpreter-0.5.2 vs lib/lisp/interpreter/core/object.rb in lisp-interpreter-0.5.3

- old
+ new

@@ -1,13 +1,16 @@ # redefine method in Object class +require 'bigdecimal' + +# Object class class Object def number? - to_f.to_s == to_s || to_i.to_s == to_s + match(/\A[-+]?[0-9]*\.?[0-9]+\Z/) end def to_num - return to_f if to_f.to_s == to_s - to_i if to_i.to_s == to_s + return to_f if to_s.include? '.' + to_i end def character? return true if self == '#\space' (start_with? '#\\') && (('a'..'z').to_a.include? self[2]) && size == 3