Class: Gdbmish::Dump::Ascii::Appender

Inherits:
Object
  • Object
show all
Defined in:
lib/gdbmish/dump.rb

Overview

Note:

Users should not use this class directly, as it only represents the data part of an dump, without header and footer.

An instance of it gets yielded when using Ascii#dump(io) { |appender| }

Appends and counts #pushed data as ASCII dump format onto the given io.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ Appender

Returns a new instance of Appender.

Parameters:

  • io (IO)

    The IO to append to



25
26
27
28
# File 'lib/gdbmish/dump.rb', line 25

def initialize(io)
  @io = io
  @count = 0
end

Instance Attribute Details

#countInteger (readonly)

Returns The number of key/value pairs pushed.

Returns:

  • (Integer)

    The number of key/value pairs pushed



22
23
24
# File 'lib/gdbmish/dump.rb', line 22

def count
  @count
end

Instance Method Details

#push(key, value) ⇒ Object

Push a key, value pair onto the dump

Parameters:

  • key (String)

    The key

  • value (String)

    The value



33
34
35
36
37
38
# File 'lib/gdbmish/dump.rb', line 33

def push(key, value)
  @count += 1
  @io << dump_datum(key)
  @io << dump_datum(value)
  nil
end