Module: FileOperation
- Included in:
- CollectTwitterMedia
- Defined in:
- lib/collect_twitter_media/file_operation.rb
Instance Method Summary collapse
- #basename_of_image_file(image_file) ⇒ Object
- #make_directory_if_not_exist(directory) ⇒ Object
- #remove_image(filename) ⇒ Object
- #to_pathname(filename_or_dirname) ⇒ Object
Instance Method Details
#basename_of_image_file(image_file) ⇒ Object
13 14 15 |
# File 'lib/collect_twitter_media/file_operation.rb', line 13 def basename_of_image_file(image_file) File.basename(image_file, '.*') end |
#make_directory_if_not_exist(directory) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/collect_twitter_media/file_operation.rb', line 4 def make_directory_if_not_exist(directory) directory = Pathname.new(to_pathname(directory)).to_s unless File.exists?(directory) command = "mkdir #{directory}" `#{command}` end directory end |
#remove_image(filename) ⇒ Object
17 18 19 |
# File 'lib/collect_twitter_media/file_operation.rb', line 17 def remove_image(filename) File.delete(filename) end |
#to_pathname(filename_or_dirname) ⇒ Object
21 22 23 |
# File 'lib/collect_twitter_media/file_operation.rb', line 21 def to_pathname(filename_or_dirname) Pathname.new(Dir.pwd).join(filename_or_dirname).to_s end |