Class: Gdbmish::Read::AsciiMetaData
- Inherits:
-
Object
- Object
- Gdbmish::Read::AsciiMetaData
- Defined in:
- lib/gdbmish/read.rb
Overview
Header and footer meta data from a GDBM Ascii dump file.
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#gid ⇒ Object
readonly
Returns the value of attribute gid.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
-
.parse(io, ignore_count: true) ⇒ Object
Parse given IO for meta data.
Instance Method Summary collapse
-
#initialize(version: nil, file: nil, uid: nil, user: nil, gid: nil, group: nil, mode: nil, count: nil) ⇒ AsciiMetaData
constructor
A new instance of AsciiMetaData.
Constructor Details
#initialize(version: nil, file: nil, uid: nil, user: nil, gid: nil, group: nil, mode: nil, count: nil) ⇒ AsciiMetaData
Returns a new instance of AsciiMetaData.
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/gdbmish/read.rb', line 85 def initialize(version: nil, file: nil, uid: nil, user: nil, gid: nil, group: nil, mode: nil, count: nil) @version = version @file = file @uid = uid @user = user @gid = gid @group = group @mode = mode @count = count end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
83 84 85 |
# File 'lib/gdbmish/read.rb', line 83 def count @count end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
83 84 85 |
# File 'lib/gdbmish/read.rb', line 83 def file @file end |
#gid ⇒ Object (readonly)
Returns the value of attribute gid.
83 84 85 |
# File 'lib/gdbmish/read.rb', line 83 def gid @gid end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
83 84 85 |
# File 'lib/gdbmish/read.rb', line 83 def group @group end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
83 84 85 |
# File 'lib/gdbmish/read.rb', line 83 def mode @mode end |
#uid ⇒ Object (readonly)
Returns the value of attribute uid.
83 84 85 |
# File 'lib/gdbmish/read.rb', line 83 def uid @uid end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
83 84 85 |
# File 'lib/gdbmish/read.rb', line 83 def user @user end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
83 84 85 |
# File 'lib/gdbmish/read.rb', line 83 def version @version end |
Class Method Details
.parse(io, ignore_count: true) ⇒ Object
Parse given IO for meta data.
Reads from +io+ until a "# End of header"
line is found (enhancing its pos
).
By default, ignores reading the count
(indecating the amount of datasets in the file)
because it is written at the end of the file.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/gdbmish/read.rb', line 100 def self.parse(io, ignore_count: true) version = nil file = nil uid = nil user = nil gid = nil group = nil mode = nil count = nil while (line = io.gets(chomp: true)) break if line == "# End of header" next unless line.start_with?("#:") line[2..].split(",") do |e| k, v = e.split("=") case k when "version" version = v when "file" file = v when "uid" uid = v when "user" user = v when "gid" gid = v when "group" group = v when "mode" mode = v.to_i(8) end end end count = read_count(io) unless ignore_count new(version: version, file: file, uid: uid, user: user, gid: gid, group: group, mode: mode, count: count) end |