Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano-exts/core_ext/string/filters.rb

Instance Method Summary collapse

Instance Method Details

#strip_empty_linesObject

Returns a string without many empty lines



3
4
5
# File 'lib/capistrano-exts/core_ext/string/filters.rb', line 3

def strip_empty_lines
  dup.strip_empty_lines!
end

#strip_empty_lines!Object



7
8
9
10
11
# File 'lib/capistrano-exts/core_ext/string/filters.rb', line 7

def strip_empty_lines!
  strip!
  gsub!(/[\n]{3,}/, "\n\n")
  self
end

#strip_trailing_whitespaceObject



13
14
15
# File 'lib/capistrano-exts/core_ext/string/filters.rb', line 13

def strip_trailing_whitespace
  dup.strip_trailing_whitespace!
end

#strip_trailing_whitespace!Object



17
18
19
20
21
# File 'lib/capistrano-exts/core_ext/string/filters.rb', line 17

def strip_trailing_whitespace!
  strip!
  gsub!(/[ \t]+$/, '')
  self
end