Sha256: 4b84de1c4f4f0a711a802b82e8a48147982dad2ec7970c301a85f73916dfd553

Contents?: true

Size: 449 Bytes

Versions: 4

Compression:

Stored size: 449 Bytes

Contents

# frozen_string_literal: true

class String
  # Checks if a line is commented out or not.
  def commented?
    start_with?("#")
  end

  # Comments a line if it is not already commented out.
  def comment
    commented? ? self : "# #{self}"
  end

  # Uncomments a line if it is commented out.
  def uncomment
    gsub(/^#\s*/, "")
  end

  # Removes whitespace from the beginning of the String.
  def strip_beginning
    gsub(/^\s*/, "")
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mozconfig-0.3 lib/core_ext/string.rb
mozconfig-0.2.1 lib/core_ext/string.rb
mozconfig-0.2 lib/core_ext/string.rb
mozconfig-0.1 lib/core_ext/string.rb