Class: MsgPacker::Decoder
- Inherits:
-
Object
- Object
- MsgPacker::Decoder
- Defined in:
- lib/msgpacker/decode.rb
Instance Method Summary collapse
- #code(is = STDIN, os = STDOUT) ⇒ Object
-
#initialize(opts = {}) ⇒ Decoder
constructor
A new instance of Decoder.
Constructor Details
#initialize(opts = {}) ⇒ Decoder
Returns a new instance of Decoder.
6 7 8 |
# File 'lib/msgpacker/decode.rb', line 6 def initialize opts = {} @options = opts.select {|k, v| [:pretty, :indent, :newline].include? k} end |
Instance Method Details
#code(is = STDIN, os = STDOUT) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/msgpacker/decode.rb', line 10 def code is = STDIN, os = STDOUT MessagePack::Unpacker.new(is).each do |obj| Yajl::Encoder.encode(obj, os, @options) os.write "\n" if @options[:newline] end end |