Class: Gdbmish::Dump::Ascii
- Inherits:
-
Object
- Object
- Gdbmish::Dump::Ascii
- Defined in:
- lib/gdbmish/dump.rb
Overview
Dumping GDBM data as ASCII (aka default) format.
Defined Under Namespace
Classes: Appender
Constant Summary collapse
- GDBM_MAX_DUMP_LINE_LEN =
GDBM does not split base64 strings at 60 encoded characters (as defined by RFC 2045).
See
_GDBM_MAX_DUMP_LINE_LEN
in gdbmdefs.h 76
Instance Method Summary collapse
-
#dump(io, data = nil) {|appender| ... } ⇒ Object
Creates a new dump file structure.
-
#initialize(file: nil, uid: nil, user: nil, gid: nil, group: nil, mode: nil) ⇒ Ascii
constructor
Builds a new Ascii format dumper.
Constructor Details
#initialize(file: nil, uid: nil, user: nil, gid: nil, group: nil, mode: nil) ⇒ Ascii
Builds a new Ascii format dumper
Dumping file information is optional.
- uid, user, gid, group and mode will only be used when file is given
- user will only be used when uid is given
- group will only be used when gid is given
74 75 76 77 78 79 80 81 |
# File 'lib/gdbmish/dump.rb', line 74 def initialize(file: nil, uid: nil, user: nil, gid: nil, group: nil, mode: nil) @file = file @uid = uid @user = user @gid = gid @group = group @mode = mode end |
Instance Method Details
#dump(io) ⇒ IO #dump(io, data) ⇒ IO #dump(io) {|appender| ... } ⇒ IO #dump(io, data) {|appender| ... } ⇒ IO
Creates a new dump file structure. Either into a given io or a new String
.
When data is given, its key/value pairs are pushed onto the dump. Key/value
objects are expected to respond to #to_s
.
When a block is given, an Appender is yielded to push key/value pairs onto the dump.
110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/gdbmish/dump.rb', line 110 def dump(io, data = nil, &block) appender = Appender.new(io) dump_header!(io) data&.each_pair do |k, v| appender.push(k.to_s, v.to_s) end yield appender if block (io, appender.count) io end |