Module: Scrubba

Defined in:
lib/scrubba.rb,
lib/scrubba/version.rb,
lib/scrubba/active_methods.rb

Defined Under Namespace

Modules: ActiveMethods

Constant Summary collapse

VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.normalize(str) ⇒ String

Converts and compresses ASCII and Unicode whitespace into single spaces.

Parameters:

  • str (String)

Returns:

  • (String)

18
19
20
# File 'lib/scrubba.rb', line 18

def self.normalize(str)
  str.gsub(/[[:space:]]+/, " ") if str
end

.scrub(str) ⇒ String

Removes leading and trailing whitespace from a string.

Parameters:

  • str (String)

Returns:

  • (String)

10
11
12
# File 'lib/scrubba.rb', line 10

def self.scrub(str)
  str.gsub(/(\A[[:space:]]+|[[:space:]]+\z)/, "") if str
end