Module: Mingle::Codec::MingleCodecs
- Defined in:
- lib/mingle/codec.rb
Constant Summary collapse
- @@bgm =
BitGirder::Core::BitGirderMethods
Class Method Summary collapse
Class Method Details
.decode(codec, obj) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/mingle/codec.rb', line 22 def decode( codec, obj ) @@bgm.not_nil( codec, :codec ) @@bgm.not_nil( obj, :obj ) case obj when String then codec.from_buffer( obj ) when IO, Tempfile data = BitGirder::Io.slurp_io( obj ) || "" decode( codec, data ) # recurse else raise "Don't know how to decode obj #{obj} of type #{obj.class}" end end |
.encode(codec, mv) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/mingle/codec.rb', line 42 def encode( codec, mv ) @@bgm.not_nil( codec, :codec ) @@bgm.not_nil( mv, :mv ) codec.as_buffer( mv ) end |