Sha256: 64252e5f0ec86200612ed1147cbff29a46132842a726378a3be14e51c5ed2c95
Contents?: true
Size: 1.12 KB
Versions: 4
Compression:
Stored size: 1.12 KB
Contents
$:.push(File.dirname(__FILE__)) require 'edn/version' require 'edn/core_ext' require 'edn/types' require 'edn/metadata' require 'edn/char_stream' require 'edn/parser' require 'edn/reader' module EDN @tags = Hash.new def self.read(edn, eof_value=NOTHING) EDN::Reader.new(edn).read(eof_value) end def self.register(tag, func = nil, &block) if block_given? func = block end if func.nil? func = lambda { |x| x } end if func.is_a?(Class) @tags[tag] = lambda { |*args| func.new(*args) } else @tags[tag] = func end end def self.unregister(tag) @tags[tag] = nil end def self.tagged_element(tag, element) func = @tags[tag] if func func.call(element) else EDN::Type::Unknown.new(tag, element) end end def self.tagout(tag, element) ["##{tag}", element.to_edn].join(" ") end def self.symbol(text) EDN::Type::Symbol.new(text) end def self.list(*values) EDN::Type::List.new(*values) end end EDN.register("inst") do |value| DateTime.parse(value) end EDN.register("uuid") do |value| EDN::Type::UUID.new(value) end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
edn-1.0.8 | lib/edn.rb |
edn-1.0.7 | lib/edn.rb |
edn-1.0.6 | lib/edn.rb |
edn-1.0.5 | lib/edn.rb |