module Gdbmish::Dump

Overview

Wrapper for different dump formats, providing various shortcut methods. Currently, there is only Ascii mode.

Ascii mode optionally dumps file information such as filename, owner, mode. See Dump::Ascii.new on how they are used.

Defined in:

gdbmish/dump.cr

Class Method Summary

Class Method Detail

def self.ascii(data : Hash | NamedTuple, io : IO, **fileoptions) : IO #

Dump data as standard ASCII format into io.

For fileoptions see Dump::Ascii.new

Example:

Gdbmish::Dump.ascii({some: "data"}, io)

[View source]
def self.ascii(data : Hash | NamedTuple, **fileoptions) : String #

Dump data as standard ASCII format into a new String.

For fileoptions see Dump::Ascii.new

Example:

dump = Gdbmish::Dump.ascii({some: "data"})

[View source]
def self.ascii(io : IO, **fileoptions, &block : Ascii::Appender -> _) : String #

Yields a Ascii::Appender which consumes key/value Tuples. Dumps a standard ASCII format into io.

For fileoptions see Dump::Ascii.new

Example:

dump = Gdbmish::Dump.ascii(io) do |appender|
  MyDataSource.each do |key, value|
    appender << {key.to_s, value.to_s}
  end
end

[View source]
def self.ascii(**fileoptions, &block : Ascii::Appender -> _) : String #

Yields a Ascii::Appender which consumes key/value Tuples. Returns a standard ASCII format as a new String.

For fileoptions see Dump::Ascii.new

Example:

dump = Gdbmish::Dump.ascii do |appender|
  MyDataSource.each do |key, value|
    appender << {key.to_s, value.to_s}
  end
end

[View source]