Module: Nanoc::StringExtensions

Included in:
String
Defined in:
lib/nanoc/base/core_ext/string.rb

Instance Method Summary (collapse)

Instance Method Details

- (String) checksum

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Calculates the checksum for this string. Any change to this string will result in a different checksum.

Returns:

  • (String)

    The checksum for this string



18
19
20
21
22
# File 'lib/nanoc/base/core_ext/string.rb', line 18

def checksum
  digest = Digest::SHA1.new
  digest.update(self)
  digest.hexdigest
end

- (String) cleaned_identifier

Transforms string into an actual identifier

Returns:

  • (String)

    The identifier generated from the receiver



8
9
10
# File 'lib/nanoc/base/core_ext/string.rb', line 8

def cleaned_identifier
  "/#{self}/".gsub(/^\/+|\/+$/, '/')
end