Class: RIO::Temp::File::RRL

Inherits:
RRL::PathBase show all
Extended by:
Fwd
Defined in:
lib/rio/scheme/temp.rb

Constant Summary collapse

RIOSCHEME =
'tempfile'
DFLT_PREFIX =
Temp::RRL::DFLT_PREFIX
DFLT_TMPDIR =
Temp::RRL::DFLT_TMPDIR

Constants inherited from RRL::PathBase

RRL::PathBase::RESET_STATE

Instance Attribute Summary

Attributes inherited from RRL::Base

#fs, #uri

Instance Method Summary collapse

Methods included from Fwd

fwd, fwd_reader, fwd_readers, fwd_writer, fwd_writers

Methods inherited from RRL::PathBase

#to_s

Methods inherited from RRL::URIBase

#initialize_copy, #openfs_, parse

Methods inherited from RRL::WithPath

#absolute?, #base, #base=, #fspath_no_slash, #host, #host=, #opaque, #openfs_, #path, #path=, #path_no_slash, #pathdepth, #pathroot, #scheme, #split

Methods included from Error::NotImplemented

#nodef

Methods inherited from RRL::Base

#==, #===, #=~, #callstr, #initialize_copy, #length, #openfs_, parse, #to_s, #url

Constructor Details

#initialize(u, file_prefix = DFLT_PREFIX, temp_dir = DFLT_TMPDIR) ⇒ RRL

Returns a new instance of RRL.



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/rio/scheme/temp.rb', line 98

def initialize(u,file_prefix=DFLT_PREFIX,temp_dir=DFLT_TMPDIR)
  require 'tempfile'
  # FIXME: Temporary fix for jruby 1.4 - make tmpdir absolute
  #tmpdir_rio = rio(@tmpdir).abs
  alturi = case u
           when ::Alt::URI::Base then u
           else ::Alt::URI.parse(u.to_s)
           end
  prefix = alturi.query || file_prefix.to_s
  tmpdir = (alturi.path.nil? || alturi.path.empty?) ? 
     temp_dir.to_s : alturi.path

  @tf = ::Tempfile.new( prefix, tmpdir)

  # FIXME: Temporary fix for jruby 1.4 - fix slashes
  pth =  @tf.path
  pth.gsub!("\\","/")
  pth = "file:///" + pth if pth =~ /^[a-zA-Z]:/

  super(::Alt::URI.parse(pth))
end

Instance Method Details

#closeObject



127
128
129
130
# File 'lib/rio/scheme/temp.rb', line 127

def close 
  super
  @tf = nil
end

#file_rlObject



121
122
123
# File 'lib/rio/scheme/temp.rb', line 121

def file_rl() 
  RIO::File::RRL.new(self.uri,{:fs => self.fs})
end

#open(mode = 'ignored') ⇒ Object



124
125
126
# File 'lib/rio/scheme/temp.rb', line 124

def open(mode='ignored')
  @tf
end