# Where is the call to tempfile in the following code?

**URL:** <https://www.ruby-forum.com/t/where-is-the-call-to-tempfile-in-the-following-code/114577>\
**Category:** Ruby\
**Created:** [September 16, 2007, 2:57am UTC](https://www.ruby-forum.com/t/where-is-the-call-to-tempfile-in-the-following-code/114577 "2007-09-16T02:57:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![overworked\_phd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/b5a626/32.png) [@overworked\_phd](https://www.ruby-forum.com/u/overworked_phd)\
**Post date:** [September 16, 2007, 2:57am UTC](https://www.ruby-forum.com/t/where-is-the-call-to-tempfile-in-the-following-code/114577/1 "2007-09-16T02:57:58Z")

</div>

At the following URL  
[http://groups.google.com/group/comp.lang.ruby/browse\_thread/thread/db](http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/db)…

There is the following code

#!/usr/local/ruby-1.8.0/bin/ruby  
require ‘ftools’  
require ‘tempfile’

def compete who, f  
5.times do |i|  
f.flock File::LOCK\_EX  
f.puts format(“%s:%d @ %f\n”,who, i, Time.now.to\_f)  
f.flock File::LOCK\_UN  
end  
end

path = format( **FILE** + ‘.out’)  
fd = open(path, File::WRONLY | File::TRUNC | File::CREAT)

if fork  
compete ‘PARENT’, fd

Process.wait rescue nil  
open(path){|f| puts f.read}  
fd.close  
File.rm\_f path if File.exist? path

else  
compete ‘CHILD’, fd  
end

The code runs on my system. But, I don’t see any call to Tempfile.new.  
I’m assuming it’s implied? If it is being implied, where is it being  
implied at in the code?

---

<div class="post-metadata">

**Author:** ![overworked\_phd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/b5a626/32.png) [@overworked\_phd](https://www.ruby-forum.com/u/overworked_phd)\
**Post date:** [September 17, 2007, 9:18am UTC](https://www.ruby-forum.com/t/where-is-the-call-to-tempfile-in-the-following-code/114577/2 "2007-09-17T09:18:03Z")

</div>

> The code runs on my system. But, I don’t see any call to Tempfile.new.  
> I’m assuming it’s implied? If it is being implied, where is it being  
> implied at in the code?

tempfile isnt used as far as my knowledge goes…to test my theory?  
delete require ‘tempfile’ … if the program still runs fine then ur  
gold.

---

<div class="post-metadata">

**Author:** ![overworked\_phd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/b5a626/32.png) [@overworked\_phd](https://www.ruby-forum.com/u/overworked_phd)\
**Post date:** [September 17, 2007, 1:23pm UTC](https://www.ruby-forum.com/t/where-is-the-call-to-tempfile-in-the-following-code/114577/3 "2007-09-17T13:23:07Z")

</div>

fd = open(path, File::WRONLY | File::TRUNC | File::CREAT)
