Class: NBTFile::CompoundWriterState

Inherits:
Object
  • Object
show all
Includes:
Tokens, WriteMethods
Defined in:
lib/nbtfile.rb

Instance Method Summary collapse

Methods included from WriteMethods

#emit_byte, #emit_byte_array, #emit_double, #emit_float, #emit_int, #emit_integer, #emit_list_header, #emit_long, #emit_short, #emit_string, #emit_type, #emit_value

Methods included from CommonMethods

#sign_bit

Constructor Details

#initialize(cont, capturing) ⇒ CompoundWriterState

Returns a new instance of CompoundWriterState.



410
411
412
413
# File 'lib/nbtfile.rb', line 410

def initialize(cont, capturing)
  @cont = cont
  @capturing = capturing
end

Instance Method Details

#emit_item(io, value) ⇒ Object

Raises:

  • (RuntimeError)


426
427
428
# File 'lib/nbtfile.rb', line 426

def emit_item(io, value)
  raise RuntimeError, "not in a list"
end

#emit_token(io, token) ⇒ Object



415
416
417
418
419
420
421
422
423
424
# File 'lib/nbtfile.rb', line 415

def emit_token(io, token)
  out = @capturing || io

  type = token.class

  emit_type(out, type)
  emit_string(out, token.name) unless type == TAG_End

  emit_value(out, type, token.value, @capturing, self, @cont)
end