Module: Win2unix
- Defined in:
- lib/win2unix.rb,
lib/win2unix/version.rb
Constant Summary collapse
- VERSION =
"0.1.2"- @@file_list =
[]
Class Method Summary collapse
Class Method Details
.get_all_files(path, ext = 'txt') ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/win2unix.rb', line 17 def self.get_all_files path, ext = 'txt' Dir.glob("#{path}/*") do |file| if File.directory? file get_all_files file else if File.extname(file) == '.' + ext @@file_list.push file end end end end |
.handle(file) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/win2unix.rb', line 29 def self.handle file origin = IO.binread file handled = origin.gsub /\r\n/, "\n" f = File.new file, 'w' f.print handled f.close end |
.tidy(path, ext = 'txt') ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/win2unix.rb', line 7 def self.tidy path, ext = 'txt' get_all_files path, ext @@file_list.each do |file| handle file end @@file_list.size end |