lib/lisp/interpreter/object.rb in lisp-interpreter-0.3.5 vs lib/lisp/interpreter/object.rb in lisp-interpreter-0.4.0

- old
+ new

@@ -8,10 +8,11 @@ return to_f if to_f.to_s == to_s return to_i if to_i.to_s == to_s end def character? + return true if self == '#\space' (start_with? '#\\') && (('a'..'z').to_a.include? self[2]) && size == 3 end def string? return false unless self.class == String @@ -31,9 +32,23 @@ end def quote? return true if start_with? '\'' false + end + + def boolean? + ['#t', '#f'].include? self + end + + def type + return 'list' if list? + return 'pair' if pair? + return 'string' if string? + return 'number' if number? + return 'character' if character? + return 'boolean' if boolean? + 'quote' end private def object_split