Sha256: b92b36bda838f979e46fe4992c821a94b219bfb2066590947f885819711f0478
Contents?: true
Size: 559 Bytes
Versions: 1
Compression:
Stored size: 559 Bytes
Contents
class File # start read the file object on each line # optionable an integer value to start read line at # compatible with mac (i am linux user, so not tested) def each_line_from(start_at=1,&block) unless [Integer,Fixnum,Bignum].include?(start_at.class) raise ArgumentError, "invalid line index" end begin line_num= 1 text= self.read text.gsub!(/\r\n?/, "\n") text.each_line do |*line| if line_num >= start_at block.call *line end line_num += 1 end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sourcerer-0.5.0.pre.beta | lib/sourcerer/file.rb |