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.



408
409
410
411
# File 'lib/nbtfile.rb', line 408

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

Instance Method Details

#emit_item(io, value) ⇒ Object

Raises:

  • (RuntimeError)


424
425
426
# File 'lib/nbtfile.rb', line 424

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

#emit_token(io, token) ⇒ Object



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

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