Sha256: 53b6ca3605ad1ee31f6077dfcd222c6b1796a32a338d7226febbc57a0cdf1992
Contents?: true
Size: 515 Bytes
Versions: 4
Compression:
Stored size: 515 Bytes
Contents
class String # Adds a comment string (`"# "`) after every newline in a string. # # @param indent_empty_lines [Boolean] # @return [void] def comment!(indent_empty_lines = true) re = indent_empty_lines ? /^/ : /^(?!$)/ gsub!(re, "# ") end # Returns a copy of a string with a comment (`"# "`) after every newline in a string. # # @param indent_empty_lines [Boolean] # @return [String] def comment(indent_empty_lines = true) dup.tap { |s| s.comment!(indent_empty_lines) } end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
coolkit-0.2.2 | lib/coolkit/string/comment.rb |
coolkit-0.2.1 | lib/coolkit/string/comment.rb |
coolkit-0.2.0 | lib/coolkit/string/comment.rb |
coolkit-0.1.0 | lib/coolkit/string/comment.rb |