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

**URL:** <https://rubytalk.org/t/where-is-the-call-to-tempfile-in-the-following-code/40651>\
**Category:** ruby-talk\
**Created:** [16 September 2007 00:57 UTC](https://rubytalk.org/t/where-is-the-call-to-tempfile-in-the-following-code/40651 "2007-09-16T00:57:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cd\_Cd](https://avatars.discourse-cdn.com/v4/letter/c/ecd19e/32.png) [@Cd\_Cd](https://rubytalk.org/u/Cd_Cd)\
**Post date:** [16 September 2007 00:57 UTC](https://rubytalk.org/t/where-is-the-call-to-tempfile-in-the-following-code/40651/1 "2007-09-16T00:57:59Z")

</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  
&nbsp;&nbsp;5.times do |i|  
&nbsp;&nbsp;&nbsp;&nbsp;f.flock File::LOCK\_EX  
&nbsp;&nbsp;&nbsp;&nbsp;f.puts format("%s:%d @ %f\n",who, i, Time.now.to\_f)  
&nbsp;&nbsp;&nbsp;&nbsp;f.flock File::LOCK\_UN  
&nbsp;&nbsp;end  
end

path = format(\_\_FILE\_\_ + '.out')  
fd = open(path, File::WRONLY | File::TRUNC | File::CREAT)

if fork  
&nbsp;&nbsp;compete 'PARENT', fd

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

else  
&nbsp;&nbsp;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?

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Marcin\_Raczkowski](https://avatars.discourse-cdn.com/v4/letter/m/ac8455/32.png) [@Marcin\_Raczkowski](https://rubytalk.org/u/Marcin_Raczkowski)\
**Post date:** [16 September 2007 11:06 UTC](https://rubytalk.org/t/where-is-the-call-to-tempfile-in-the-following-code/40651/2 "2007-09-16T11:06:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jon\_Hawkins](https://avatars.discourse-cdn.com/v4/letter/j/958977/32.png) [@Jon\_Hawkins](https://rubytalk.org/u/Jon_Hawkins)\
**Post date:** [17 September 2007 07:18 UTC](https://rubytalk.org/t/where-is-the-call-to-tempfile-in-the-following-code/40651/3 "2007-09-17T07:18:04Z")

</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.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
