Class: StringLineReader

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

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ StringLineReader

Returns a new instance of StringLineReader.



14
15
16
# File 'lib/textutils/reader/line_reader.rb', line 14

def initialize( data )
  @data = data
end

Instance Method Details

#each_lineObject



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

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