Module: Minescope::Transcoder
- Extended by:
- Transcoder
- Includes:
- NBTFile::Tokens
- Included in:
- Transcoder
- Defined in:
- lib/minescope/transcoder.rb
Defined Under Namespace
Classes: CompactPrinter, PrettyPrinter
Instance Method Summary collapse
Instance Method Details
#transcode(io, options = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/minescope/transcoder.rb', line 42 def transcode(io, ={}) tokens = NBTFile.enum_for(:tokenize, io) if [:prettyprint] formatter = PrettyPrinter.new else formatter = CompactPrinter.new end y = [] y << "[" token = tokens.next # head token y << token.name.to_json y << formatter.item_separator generate_compound(y, tokens, formatter) y << "]" y.join end |