vendor/gems/BlueCloth-1.0.0/utils.rb
### Open a file and filter each of its lines through the given block a
### <tt>line</tt> at a time. The return value of the block is used as the
### new line, or omitted if the block returns <tt>nil</tt> or
### <tt>false</tt>.
Open a file and filter each of its lines through the given block a
line at a time. The return value of the block is used as the
new line, or omitted if the block returns nil or
false.
Open a file and filter each of its lines through the given block a line at a time . The return value of the block is used as the new line or omitted if the block returns nil or false .
def editInPlace( file ) 
		raise "No block specified for editing operation" unless block_given?
		tempName = "#{file}.#{$$}"
		File::open( tempName, File::RDWR|File::CREAT, 0600 ) {|tempfile|
			File::unlink( tempName )
			File::open( file, File::RDONLY ) {|fh|
				fh.each {|line|
					newline = yield( line ) or next
					tempfile.print( newline )
				}
			}
			tempfile.seek(0)
			File::open( file, File::TRUNC|File::WRONLY, 0644 ) {|newfile|
				newfile.print( tempfile.read )
			}
		}
	end
def editInPlace ( file ) raise "No block specified for editing operation" unless block_given? tempName = "#{file}.#{$$}" File :: open ( tempName , File :: RDWR | File :: CREAT , 0600 ) { | tempfile | File :: unlink ( tempName ) File :: open ( file , File :: RDONLY ) { | fh | fh . each { | line | newline = yield ( line ) or next tempfile . print ( newline ) } } tempfile . seek ( 0 ) File :: open ( file , File :: TRUNC | File :: WRONLY , 0644 ) { | newfile | newfile . print ( tempfile . read ) } } end
Open a file and filter each of its lines through the given block a
<tt>line</tt> at a time.
Open a file and filter each of its lines through the given block a <tt > line< / tt > at a time .
# :yields: line
file
<not_specific>