Class: StringLineReader

Inherits:
Object
  • Object
show all
Includes:
LogUtils::Logging
Defined in:
lib/textutils/reader/line_reader.rb

Overview

fix/todo: move to/merge into LineReader itself

e.g. use  fromString c'tor ??? or similar??

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ StringLineReader

Returns a new instance of StringLineReader.



11
12
13
# File 'lib/textutils/reader/line_reader.rb', line 11

def initialize( data )
  @data = data
end

Instance Method Details

#each_lineObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/textutils/reader/line_reader.rb', line 16

def each_line
  @data.each_line do |line|

    if line =~ /^\s*#/
      # skip komments and do NOT copy to result (keep comments secret!)
      logger.debug 'skipping comment line'
      next
    end
      
    if line =~ /^\s*$/ 
      # kommentar oder leerzeile überspringen 
      logger.debug 'skipping blank line'
      next
    end

    # remove leading and trailing whitespace
    line = line.strip
 
    yield( line )
  end # each lines
end