Class: LineReader
- Inherits:
-
Object
- Object
- LineReader
- Includes:
- LogUtils::Logging
- Defined in:
- lib/textutils/reader/line_reader.rb
Instance Method Summary collapse
- #each_line ⇒ Object
-
#initialize(path) ⇒ LineReader
constructor
A new instance of LineReader.
Constructor Details
#initialize(path) ⇒ LineReader
Returns a new instance of LineReader.
48 49 50 51 52 53 54 |
# File 'lib/textutils/reader/line_reader.rb', line 48 def initialize( path ) @path = path ## nb: assume/enfore utf-8 encoding (with or without BOM - byte order mark) ## - see textutils/utils.rb @data = File.read_utf8( @path ) end |
Instance Method Details
#each_line ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/textutils/reader/line_reader.rb', line 56 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 |