Module: Kernel
- Defined in:
- lib/open-temporary.rb
Constant Summary collapse
- @@open =
self.method(:open)
Instance Method Summary collapse
-
#open(*argv, &block) ⇒ Object
If non-zero numbers of args are passed, works as it ought.
Instance Method Details
#open(*argv, &block) ⇒ Object
If non-zero numbers of args are passed, works as it ought. otherwise creates and opens a temporay file.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/open-temporary.rb', line 49 def open(*argv, &block) if argv.size.nonzero? @@open.call(*argv, &block) elsif block_given? begin f = self.open_temporary yield f ensure f.close end else File.open end end |