Class: Glark::IO::LinesCR
Instance Method Summary collapse
- #each_line(&blk) ⇒ Object
-
#get_lines ⇒ Object
Returns the lines for this file, separated by end of line sequences.
- #get_region(rnum) ⇒ Object
-
#initialize(fname, io) ⇒ LinesCR
constructor
A new instance of LinesCR.
Methods inherited from Lines
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_lines ⇒ Object
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 |