Class: Gdbmish::Read::AsciiDataIterator
- Inherits:
-
Object
- Object
- Gdbmish::Read::AsciiDataIterator
- Includes:
- Enumerable
- Defined in:
- lib/gdbmish/read.rb
Overview
Note:
Users should not need to use this directly, but rather Gdbmish::Read::Ascii#data.
Iterates over data and returns decoded key/value pairs.
Instance Method Summary collapse
-
#each {|String, String| ... } ⇒ Object
Iterates over key/value pairs, decoding them.
-
#initialize(io, encoding: Encoding::UTF_8) ⇒ AsciiDataIterator
constructor
A new instance of AsciiDataIterator.
Constructor Details
#initialize(io, encoding: Encoding::UTF_8) ⇒ AsciiDataIterator
Returns a new instance of AsciiDataIterator.
209 210 211 212 |
# File 'lib/gdbmish/read.rb', line 209 def initialize(io, encoding: Encoding::UTF_8) @iterator = AsciiLineIterator.new(io) @encoding = encoding end |
Instance Method Details
#each {|String, String| ... } ⇒ Object
Iterates over key/value pairs, decoding them.
216 217 218 219 220 221 222 |
# File 'lib/gdbmish/read.rb', line 216 def each @iterator.each_slice(2) do |k, v| k = Base64.decode64(k).force_encoding(@encoding) v = Base64.decode64(v).force_encoding(@encoding) unless v.nil? yield [k, v] end end |