Class: Glark::IO::LinesCR

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

Instance Method Summary collapse

Methods inherited from Lines

#count, #get_line

Constructor Details

#initialize(fname, io) ⇒ LinesCR

Returns a new instance of LinesCR.



30
31
32
33
34
# File 'lib/glark/util/io/lines.rb', line 30

def initialize fname, io
  super fname
  @lines = Array.new
  @io = io
end

Instance Method Details

#each_line(&blk) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/glark/util/io/lines.rb', line 41

def each_line &blk
  while (line = @io.gets) && line.length > 0
    @lines << line
    blk.call line
  end
  @io.close
end

#get_linesObject

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



37
38
39
# File 'lib/glark/util/io/lines.rb', line 37

def get_lines
  return @lines
end

#get_region(rnum) ⇒ Object



49
50
51
52
# File 'lib/glark/util/io/lines.rb', line 49

def get_region rnum
  # easy case: range is the range number, unless it is out of range.
  return rnum < @lines.length ? (rnum .. rnum) : nil
end