Class: BashCommentFormatter

Inherits:
Object show all
Defined in:
lib/hash_delegator.rb

Class Method Summary collapse

Class Method Details

.format_comment(input_string) ⇒ Object

Formats a multi-line string into a format safe for use

in Bash comments.


431
432
433
434
435
436
437
438
439
# File 'lib/hash_delegator.rb', line 431

def self.format_comment(input_string)
  return '# ' if input_string.nil?
  return '# ' if input_string.empty?

  formatted = input_string.split("\n").map do |line|
    "# #{line.gsub('#', '\#')}"
  end
  formatted.join("\n")
end