Class: Glark::IO::LinesNonCR

Inherits:
Lines
  • Object
show all
Defined in:
lib/glark/util/io/lines.rb

Constant Summary collapse

ANY_END_OF_LINE =

cross-platform end of line: DOS UNIX MAC

Regexp.new '(?:\r\n|\n|\r)'

Instance Method Summary collapse

Methods inherited from Lines

#count, #get_line

Constructor Details

#initialize(fname, io) ⇒ LinesNonCR

Returns a new instance of LinesNonCR.



59
60
61
62
63
64
# File 'lib/glark/util/io/lines.rb', line 59

def initialize fname, io
  super fname
  @extracted = nil
  @regions = nil
  @lines = ::IO::readlines fname
end

Instance Method Details

#each_line(&blk) ⇒ Object



66
67
68
69
70
# File 'lib/glark/util/io/lines.rb', line 66

def each_line &blk
  @lines.each do |line|
    blk.call line
  end
end

#get_linesObject

Returns the lines for this file, separated by end of line sequences.



73
74
75
# File 'lib/glark/util/io/lines.rb', line 73

def get_lines
  @extracted ||= create_extracted
end

#get_region(rnum) ⇒ Object

returns the region/range that is represented by the region number



78
79
80
81
# File 'lib/glark/util/io/lines.rb', line 78

def get_region rnum
  @regions ||= create_regions
  @regions[rnum]
end