Class: LocalResource::Instance

Inherits:
Object
  • Object
show all
Defined in:
lib/local_resource/instance.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, tmp_filename) ⇒ Instance

Returns a new instance of Instance.



3
4
5
6
7
# File 'lib/local_resource/instance.rb', line 3

def initialize(url, tmp_filename)
  @url = url
  @tmp_file_name = File.basename(tmp_filename, ".*")
  @tmp_file_ext = File.extname(tmp_filename)
end

Class Method Details

.tmp_dirObject



23
24
25
26
# File 'lib/local_resource/instance.rb', line 23

def self.tmp_dir
  path = Rails.root.join('tmp/local_resources')
  FileUtils::mkdir_p(path.to_s).first
end

Instance Method Details

#destroyObject



17
18
19
20
21
# File 'lib/local_resource/instance.rb', line 17

def destroy
  return unless @file
  @file.delete
  @file = nil
end

#fileObject



9
10
11
# File 'lib/local_resource/instance.rb', line 9

def file
  @file ||= load_tempfile
end

#file_pathObject



13
14
15
# File 'lib/local_resource/instance.rb', line 13

def file_path
  file.path
end