Class: BashCommentFormatter
Class Method Summary collapse
-
.format_comment(input_string) ⇒ Object
Formats a multi-line string into a format safe for use in Bash comments.
Class Method Details
.format_comment(input_string) ⇒ Object
Formats a multi-line string into a format safe for use in Bash comments.
400 401 402 403 404 405 406 407 408 |
# File 'lib/hash_delegator.rb', line 400 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 |