Class: Gdbmish::Read::AsciiLineIterator
- Inherits:
-
Object
- Object
- Gdbmish::Read::AsciiLineIterator
- 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 lines, skipping comments, joining wrapped lines. Lines are alternating key or value in encoded form.
Constant Summary collapse
- COMMENT_BYTE =
Comment lines start with '#'
"#".ord
Instance Method Summary collapse
-
#each {|String| ... } ⇒ Object
Iterates over encoded lines, skipping comments, joining wrapped lines.
-
#initialize(io) ⇒ AsciiLineIterator
constructor
A new instance of AsciiLineIterator.
Constructor Details
#initialize(io) ⇒ AsciiLineIterator
Returns a new instance of AsciiLineIterator.
173 174 175 |
# File 'lib/gdbmish/read.rb', line 173 def initialize(io) @io = io end |
Instance Method Details
#each {|String| ... } ⇒ Object
Iterates over encoded lines, skipping comments, joining wrapped lines.
179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/gdbmish/read.rb', line 179 def each while (line = @io.gets(chomp: true)) next if line.bytes.first == COMMENT_BYTE data = line.dup until next_is_comment? data << @io.gets(chomp: true) end yield data end end |