Sha256: 8c5e66a53a46503c217b55ac23a258197fac565c0452fd7ac2929e7d716d0d1d

Contents?: true

Size: 290 Bytes

Versions: 1

Compression:

Stored size: 290 Bytes

Contents

module BSielski
  class TrunctateByChar
    def initialize(limit:, suffix:)
      @limit, @suffix = limit, suffix
    end
    def call(string)
      raise "no options" unless @limit
      return string unless @limit < string.length
      "#{string[0...@limit]}#{@suffix}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bsielski-trunctate-0.1.0 lib/bsielski/trunctate_by_char.rb