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.


539
540
541
542
543
544
545
546
547
# File 'lib/hash_delegator.rb', line 539

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