Module: Nomener::Base

Included in:
Parser, Suffixes, Titles
Defined in:
lib/nomener/base.rb

Overview

Module of constants, methods being used in other modules and classes

Constant Summary collapse

PERIOD =

probably unnecessary constant

/\./

Instance Method Summary collapse

Instance Method Details

#dustoff(str) ⇒ Object

Internal: a softer clean we keep re-using

str - the string to dust off

Returns the nice clean



12
13
14
15
16
# File 'lib/nomener/base.rb', line 12

def dustoff(str)
  str = str.gsub PERIOD, ' '
  str = str.squeeze ' '
  str.strip
end

#gut!(str = '', pattern = / /) ⇒ Object

Internal: clean out a given string with a given pattern

Modfies the given string

str - the string to gut pattern - the regext to cut with

Returns the gutted pattern



25
26
27
28
29
30
31
32
# File 'lib/nomener/base.rb', line 25

def gut!(str = '', pattern = / /)
  found = []
  str.gsub! pattern do |pat|
    found << pat.strip
    ''
  end
  found.join ' '
end