Module: RemoveDoubleBlank
- Defined in:
- lib/remove_double_blank.rb,
lib/remove_double_blank/version.rb
Constant Summary collapse
- VERSION =
'0.0.0'.freeze
Class Method Summary collapse
Class Method Details
.update(path) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/remove_double_blank.rb', line 5 def self.update(path) path_old = path path_new = "#{path_old}.new" file_w = open(path_new, 'w') n_empty = 0 File.readlines(path_old).each do |line| if line == "\n" n_empty += 1 else n_empty = 0 end file_w.write line if n_empty < 2 end file_w.close system("rm #{path_old}") system("mv #{path_new} #{path_old}") end |