Class: LocalResource::Instance
- Inherits:
-
Object
- Object
- LocalResource::Instance
- Defined in:
- lib/local_resource/instance.rb
Class Method Summary collapse
Instance Method Summary collapse
- #destroy ⇒ Object
- #file ⇒ Object
- #file_path ⇒ Object
-
#initialize(url, tmp_filename) ⇒ Instance
constructor
A new instance of Instance.
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_dir ⇒ Object
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
#destroy ⇒ Object
17 18 19 20 21 |
# File 'lib/local_resource/instance.rb', line 17 def destroy return unless @file @file.delete @file = nil end |
#file ⇒ Object
9 10 11 |
# File 'lib/local_resource/instance.rb', line 9 def file @file ||= load_tempfile end |
#file_path ⇒ Object
13 14 15 |
# File 'lib/local_resource/instance.rb', line 13 def file_path file.path end |