Class: Krikri::Enrichments::StripWhitespace

Inherits:
Object
  • Object
show all
Includes:
FieldEnrichment
Defined in:
lib/krikri/enrichments/strip_whitespace.rb

Overview

Strip whitespace

StripWhitespace.new.enrich_value("\tmoominpapa  \t  \nmoominmama  ")
# => ['moominpapa', 'moominmama']

Constant Summary

Constants included from SoftwareAgent

SoftwareAgent::Logger

Instance Method Summary collapse

Methods included from FieldEnrichment

#enrich, #enrich_all, #enrich_field

Methods included from Krikri::Enrichment

#enrich, #enrich!, #list_fields

Methods included from SoftwareAgent

#agent_name, #log, #run

Instance Method Details

#enrich_value(value) ⇒ Object


10
11
12
13
# File 'lib/krikri/enrichments/strip_whitespace.rb', line 10

def enrich_value(value)
  return value unless value.is_a? String
  value.strip.gsub(/\s+/, ' ')
end