Sha256: 39a873cdeb5c741984a1dd833b6e708a0f8dba0ecfa6b01bde4a0fcef1552f4b

Contents?: true

Size: 497 Bytes

Versions: 35

Compression:

Stored size: 497 Bytes

Contents

module Krikri::Enrichments
  ##
  # 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 '...'
  #
  class LimitCharacters
    include Audumbla::FieldEnrichment

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

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
krikri-0.15.2 lib/krikri/enrichments/limit_characters.rb
krikri-0.15.1 lib/krikri/enrichments/limit_characters.rb
krikri-0.15.0 lib/krikri/enrichments/limit_characters.rb
krikri-0.14.0 lib/krikri/enrichments/limit_characters.rb
krikri-0.13.2 lib/krikri/enrichments/limit_characters.rb
krikri-0.13.1 lib/krikri/enrichments/limit_characters.rb
krikri-0.13.0 lib/krikri/enrichments/limit_characters.rb
krikri-0.12.4 lib/krikri/enrichments/limit_characters.rb
krikri-0.12.3 lib/krikri/enrichments/limit_characters.rb
krikri-0.12.1 lib/krikri/enrichments/limit_characters.rb
krikri-0.12.0 lib/krikri/enrichments/limit_characters.rb
krikri-0.12.0.pre.rc.1 lib/krikri/enrichments/limit_characters.rb
krikri-0.11.2 lib/krikri/enrichments/limit_characters.rb
krikri-0.11.1 lib/krikri/enrichments/limit_characters.rb
krikri-0.11.0 lib/krikri/enrichments/limit_characters.rb
krikri-0.10.1 lib/krikri/enrichments/limit_characters.rb
krikri-0.10.0 lib/krikri/enrichments/limit_characters.rb
krikri-0.9.0 lib/krikri/enrichments/limit_characters.rb
krikri-0.8.9 lib/krikri/enrichments/limit_characters.rb
krikri-0.8.8 lib/krikri/enrichments/limit_characters.rb