summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2018-08-05 17:43:59 +0200
committerLeah Neukirchen <leah@vuxu.org>2018-08-05 17:43:59 +0200
commit2ffed364f8a9db879eb270abb39427ed9ed9a725 (patch)
treea8c284bb4ebe495ed9f6eba4fb5077225726e1b1
parent29676c717eac0f2c5e6cc02941b479dd5d81727c (diff)
downloadsson-2ffed364f8a9db879eb270abb39427ed9ed9a725.tar.gz
sson-2ffed364f8a9db879eb270abb39427ed9ed9a725.tar.xz
sson-2ffed364f8a9db879eb270abb39427ed9ed9a725.zip
move exception classes to SSON module
-rw-r--r--lib/sson.rb16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/sson.rb b/lib/sson.rb
index 684749a..dd4ea67 100644
--- a/lib/sson.rb
+++ b/lib/sson.rb
@@ -18,16 +18,16 @@ require 'json'
 require 'prettyprint'
 require 'strscan'
 
-module SSON; end
-class << SSON
+module SSON
   VERSION = "0.1"
-               
-  SCANIDENT = /[^0-9#;()" \t\r\n+-][^#;()" \t\r\n]*/
-  IDENT = /\A#{SCANIDENT}\z/
 
   class SSONError < StandardError; end
   class GeneratorError < SSONError; end
   class ParserError < SSONError; end
+end
+class << SSON
+  SCANIDENT = /[^0-9#;()" \t\r\n+-][^#;()" \t\r\n]*/
+  IDENT = /\A#{SCANIDENT}\z/
 
   def generate(o)
     case o
@@ -137,7 +137,7 @@ class << SSON
     rescue StopIteration
       r
     else
-      raise ParserError, "trailing garbage"
+      raise SSON::ParserError, "trailing garbage"
     end
   end
 
@@ -161,7 +161,7 @@ class << SSON
       elsif s = ss.scan(/[-+]?(?:\d*\.?\d+|\d+\.?\d*)(?:[eE][-+]?\d+)?/)
         yield Float(s)
       else
-        raise ParserError, "invalid SSON: " + ss.peek(20).dump
+        raise SSON::ParserError, "invalid SSON: " + ss.peek(20).dump
       end
     end
   end
@@ -185,7 +185,7 @@ class << SSON
       end
       e.next
       r
-    when :CLOSE;   raise ParserError, "invalid SSON, toplevel )"
+    when :CLOSE;   raise SSON::ParserError, "invalid SSON, toplevel )"
     when :NULL;    nil
     when :TRUE;    true
     when :FALSE;   false