Class: Gct::TempLocalFile
- Inherits:
-
Object
- Object
- Gct::TempLocalFile
- Defined in:
- lib/gct/temp_local_file.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#file_name ⇒ Object
Returns the value of attribute file_name.
Instance Method Summary collapse
- #full_path ⇒ Object
-
#initialize(content = '', file_name = '') ⇒ TempLocalFile
constructor
A new instance of TempLocalFile.
- #read ⇒ Object
- #read_path_file(path, file) ⇒ Object
- #tmp_folder ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(content = '', file_name = '') ⇒ TempLocalFile
Returns a new instance of TempLocalFile.
7 8 9 10 |
# File 'lib/gct/temp_local_file.rb', line 7 def initialize(content = '', file_name = '') @content = content @file_name = file_name end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
3 4 5 |
# File 'lib/gct/temp_local_file.rb', line 3 def content @content end |
#file_name ⇒ Object
Returns the value of attribute file_name.
5 6 7 |
# File 'lib/gct/temp_local_file.rb', line 5 def file_name @file_name end |
Instance Method Details
#full_path ⇒ Object
45 46 47 |
# File 'lib/gct/temp_local_file.rb', line 45 def full_path tmp_folder end |
#read ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gct/temp_local_file.rb', line 23 def read begin file = File.open(tmp_folder, "r") file.read rescue IOError => e raise e. ensure file.close unless file.nil? end end |
#read_path_file(path, file) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/gct/temp_local_file.rb', line 34 def read_path_file(path, file) begin file = File.new(File.join(path, file), "r") file.read rescue IOError => e raise e. ensure file.close unless file.nil? end end |
#tmp_folder ⇒ Object
49 50 51 |
# File 'lib/gct/temp_local_file.rb', line 49 def tmp_folder "#{Generator::GctFile.temp_folder_path}/#{file_name}" end |
#write ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/gct/temp_local_file.rb', line 12 def write begin file = File.open(tmp_folder, "w") file.write(@content) rescue IOError => e raise e. ensure file.close unless file.nil? end end |