Class: IFF::Emitter

Inherits:
Object
  • Object
show all
Includes:
ParserEmitterCommon
Defined in:
lib/iff.rb

Instance Method Summary collapse

Methods included from ParserEmitterCommon

#initialize, #padding_required_for?

Instance Method Details

#emit(chunk) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/iff.rb', line 96

def emit( chunk )
  unless @seekable
    content = chunk.serialize( StringIO.new( "", "w" ), @options ).string
    emit_header_and_footer( chunk.tag, content.length ) do
      @stream << content
    end
  else
    header_pos = @stream.pos
    chunk.serialize( @stream << HEADER_PADDING, @options )
    length = @stream.pos - header_pos - HEADER_LENGTH

    @stream.pos = header_pos
    emit_header_and_footer( chunk.tag, length ) do
      @stream.pos += length
    end
  end

  self
end