Class: Tempfile
Class Method Summary collapse
-
.path(content, dir = Dir.tmpdir) ⇒ Object
Create a temporary file whose contents is CONTENT.
-
.pathname(content, dir = Dir.tmpdir) ⇒ Object
Similar to Tempfile.path.
Class Method Details
.path(content, dir = Dir.tmpdir) ⇒ Object
Create a temporary file whose contents is CONTENT. Returns the file’s path.
147 148 149 150 151 152 153 |
# File 'lib/el4r/el4r-sub.rb', line 147 def path(content, dir=Dir.tmpdir) x = Tempfile.open("content", dir) x.write content x.close x.open x.path end |
.pathname(content, dir = Dir.tmpdir) ⇒ Object
Similar to Tempfile.path. But returns Pathname object.
156 157 158 |
# File 'lib/el4r/el4r-sub.rb', line 156 def pathname(content, dir=Dir.tmpdir) Pathname.new(path(content, dir=Dir.tmpdir)) end |