class FSPath::Tempfile
Extension of Tempfile
returning instance of provided class for path
Public Class Methods
new(path_klass, *args)
click to toggle source
Eats first argument which must be a class, and calls super
Calls superclass method
# File lib/fspath.rb, line 13 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
open(*args) { |tempfile| ... }
click to toggle source
Fixes using appropriate initializer for jruby in 1.8 mode, also returns result of block in ruby 1.8
# File lib/fspath.rb, line 29 def self.open(*args) tempfile = new(*args) if block_given? begin yield(tempfile) ensure tempfile.close end else tempfile end end
Public Instance Methods
path()
click to toggle source
Returns path wrapped in class provided in initialize
Calls superclass method
# File lib/fspath.rb, line 23 def path @path_klass.new(super) end