Class: Krikri::Enrichments::LimitCharacters

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

Overview

Enrichment to limit the number of characters in a string to 1000

@example: Limit a String
LimitCharacters.new.enrich_value(string_with_over_1000_characters)
 => truncated string ending in '...'

Instance Method Summary collapse

Instance Method Details

#enrich_value(value) ⇒ Object



12
13
14
15
16
# File 'lib/krikri/enrichments/limit_characters.rb', line 12

def enrich_value(value)
  return value unless value.is_a? String
  return value unless value.length > 1000
  value.truncate(1000, separator: /\s/)
end