Class JCON::DefaultDictionary
In: lib/jcon/dictionary.rb
Parent: Dictionary

Methods

Public Class methods

[Source]

    # File lib/jcon/dictionary.rb, line 39
39:     def initialize
40:       super(nil)
41:       add_builtin_definitions
42:     end

Public Instance methods

[Source]

    # File lib/jcon/dictionary.rb, line 44
44:     def add_builtin_definitions
45:       deftype(:*) do true end
46:       deftype(:null) do |x| x.nil? end
47:       deftype(:undefined) do |x| x.nil? end
48:       deftype(:Object) do true end
49:       deftype(:Array)
50:       deftype(:Date)
51:       deftype(:RegExp, Regexp)
52:       deftype(:Boolean, [false,true,nil])
53:       deftype(:String)
54:       deftype(:Number, Numeric)
55:       deftype(:boolean, [false,true])
56:       deftype(:string) do |x| x.is_a?(String) end
57:       deftype(:int) do |x| x.is_a?(Integer) end
58:       deftype(:uint) do |x| x.is_a?(Integer) and x > 0 end
59:       deftype(:double) do |x| x.is_a?(Numeric) end
60:       deftype(:decimal) do |x| x.is_a?(Numeric) end
61:       deftype :AnyString, union(:string, String)
62:       deftype :AnyBoolean, union(:boolean, :Boolean) 
63:       deftype :AnyNumber, union(:byte, :int, :uint, :double, :decimal,:Number) 
64:       deftype :FloatNumber, union(:double, :decimal) 
65:     end

[Validate]