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.



6
7
8
9
10
# File 'lib/local_resource/instance.rb', line 6

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



26
27
28
29
# File 'lib/local_resource/instance.rb', line 26

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

Instance Method Details

#destroyObject



20
21
22
23
24
# File 'lib/local_resource/instance.rb', line 20

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

#fileObject



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

def file
  @file ||= load_tempfile
end

#file_pathObject



16
17
18
# File 'lib/local_resource/instance.rb', line 16

def file_path
  file.path
end