Class String
In: lib/facets/core-uncommon/facets/string/acronym.rb
lib/facets/core-uncommon/facets/string/crypt.rb
lib/facets/core-uncommon/facets/integer/roman.rb
Parent: Object

Methods

acronymize   crypt  

Constants

ROMAN = /^M*(D?C{0,3}|C[DM])(L?X{0,3}|X[LC])(V?I{0,3}|I[VX])$/i unless const_defined?(:ROMAN)   Taken from O‘Reilly‘s Perl Cookbook 6.23. Regular Expression Grabbag.
ROMAN_VALUES = Integer::ROMAN_VALUES.inject({}) do |h,(r,a)| h[r] = a;

External Aliases

crypt -> _crypt

Public Instance methods

CREDIT: Robert Fey

[Source]

# File lib/facets/core-uncommon/facets/string/acronym.rb, line 4
  def acronymize
          gsub(/(([a-zA-Z0-9])([a-zA-Z0-9])*)./,"\\2")
  end

Common Unix cryptography method. This adds a default salt to the built-in crypt method.

NOTE: This is not (presently) a common core extension and is not loaded automatically when using require ‘facets‘.

[Source]

# File lib/facets/core-uncommon/facets/string/crypt.rb, line 11
  def crypt(salt=nil)
    salt ||= (
      (rand(26) + (rand(2) == 0 ? 65 : 97) ).chr +
      (rand(26) + (rand(2) == 0 ? 65 : 97) ).chr
    )
    _crypt(salt)
  end

[Validate]