Class: CsvUploader
- Inherits:
-
Object
- Object
- CsvUploader
- Defined in:
- lib/csv_uploader_tool/csv_uploader.rb
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
Class Method Summary collapse
- .create(dir = 'public/upload') ⇒ Object
- .fetch(dir) ⇒ Object
- .mkdir(dir) ⇒ Object
- .remove_all_for(dir) ⇒ Object
- .size(dir) ⇒ Object
Instance Method Summary collapse
-
#initialize(dir) ⇒ CsvUploader
constructor
A new instance of CsvUploader.
- #save(stream) {|file| ... } ⇒ Object
Constructor Details
#initialize(dir) ⇒ CsvUploader
5 6 7 8 |
# File 'lib/csv_uploader_tool/csv_uploader.rb', line 5 def initialize(dir) self.class.mkdir dir @dir = dir end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
3 4 5 |
# File 'lib/csv_uploader_tool/csv_uploader.rb', line 3 def dir @dir end |
Class Method Details
.create(dir = 'public/upload') ⇒ Object
11 12 13 |
# File 'lib/csv_uploader_tool/csv_uploader.rb', line 11 def create(dir = 'public/upload') CsvUploader.new dir end |
.fetch(dir) ⇒ Object
19 20 21 |
# File 'lib/csv_uploader_tool/csv_uploader.rb', line 19 def fetch(dir) CsvStream.fetch dir end |
.mkdir(dir) ⇒ Object
15 16 17 |
# File 'lib/csv_uploader_tool/csv_uploader.rb', line 15 def mkdir(dir) FileUtils.mkpath dir unless File.directory?(dir) end |
.remove_all_for(dir) ⇒ Object
27 28 29 |
# File 'lib/csv_uploader_tool/csv_uploader.rb', line 27 def remove_all_for(dir) FileUtils.remove_dir dir end |
.size(dir) ⇒ Object
23 24 25 |
# File 'lib/csv_uploader_tool/csv_uploader.rb', line 23 def size(dir) File.absolute_path(dir).size end |
Instance Method Details
#save(stream) {|file| ... } ⇒ Object
32 33 34 35 |
# File 'lib/csv_uploader_tool/csv_uploader.rb', line 32 def save(stream) file = save_stream(stream) yield file if block_given? end |