Class: NBTFile::Private::CompoundEmitterState

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

Instance Method Summary collapse

Methods included from EmitMethods

#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) ⇒ CompoundEmitterState

Returns a new instance of CompoundEmitterState.



438
439
440
441
# File 'lib/nbtfile.rb', line 438

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

Instance Method Details

#emit_item(io, value) ⇒ Object

Raises:

  • (RuntimeError)


454
455
456
# File 'lib/nbtfile.rb', line 454

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

#emit_token(io, token) ⇒ Object



443
444
445
446
447
448
449
450
451
452
# File 'lib/nbtfile.rb', line 443

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