Class: FSPath::Tempfile
- Inherits:
-
Tempfile
- Object
- Tempfile
- FSPath::Tempfile
- Defined in:
- lib/fspath.rb
Overview
Extension of Tempfile returning instance of provided class for path
Class Method Summary collapse
-
.open(*args) ⇒ Object
Fixes using appropriate initializer for jruby in 1.8 mode, also returns result of block in ruby 1.8.
Instance Method Summary collapse
-
#initialize(path_klass, *args) ⇒ Tempfile
constructor
Eats first argument which must be a class, and calls super.
-
#path ⇒ Object
Returns path wrapped in class provided in initialize.
Constructor Details
#initialize(path_klass, *args) ⇒ Tempfile
Eats first argument which must be a class, and calls super
11 12 13 14 15 16 17 |
# File 'lib/fspath.rb', line 11 def initialize(path_klass, *args) unless path_klass.is_a?(Class) fail ArgumentError, "#{path_klass.inspect} is not a class" end @path_klass = path_klass super(*args) end |
Class Method Details
.open(*args) ⇒ Object
Fixes using appropriate initializer for jruby in 1.8 mode, also returns result of block in ruby 1.8
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fspath.rb', line 26 def self.open(*args) tempfile = new(*args) if block_given? begin yield(tempfile) ensure tempfile.close end else tempfile end end |
Instance Method Details
#path ⇒ Object
Returns path wrapped in class provided in initialize
20 21 22 |
# File 'lib/fspath.rb', line 20 def path @path_klass.new(super) end |