# File lib/cerealize.rb, line 35
35: def codec_detect(str)
36: codecs.find{ |codec| codec.yours?(str) }
37: end
# File lib/cerealize.rb, line 39
39: def codec_get(codec_name)
40: Codec.const_get(codec_name.to_s.capitalize)
41: rescue NameError
42: raise NoSuchCodec.new(codec_name)
43: end
# File lib/cerealize.rb, line 31
31: def codec_names
32: @codec_names ||= [:yaml, :marshal]
33: end
# File lib/cerealize.rb, line 25
25: def codecs
26: @codecs ||= codec_names.map{ |codec_name|
27: codec_get(codec_name)
28: }
29: end
# File lib/cerealize.rb, line 50
50: def decode(str, codec=nil)
51: return nil unless str
52: codec ||= codec_detect(str)
53:
54: if codec && codec.yours?(str)
55: codec.decode(str)
56: else
57: raise NoSuitableCodec.new("#{str[0..46]}...")
58: end
59: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.