Sha256: 7650646d04e792cf55ba777d3ae20718ae1529ded283711fbb215d289d46301b
Contents?: true
Size: 819 Bytes
Versions: 1
Compression:
Stored size: 819 Bytes
Contents
if RUBY_ENGINE_JRUBY class String # Safely truncate the string to the specified number of bytes. # If a multibyte char gets split, the dangling fragment is removed. def limit size return self unless size < bytesize result = (unpack %(a#{size}))[0] begin result.unpack 'U*' rescue ArgumentError result.chop! retry end result end unless method_defined? :limit end else class String # Safely truncate the string to the specified number of bytes. # If a multibyte char gets split, the dangling fragment is removed. def limit size return self unless size < bytesize result = (unpack %(a#{size}))[0] result.chop! until result.empty? || /.$/u =~ result result end unless method_defined? :limit end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
asciidoctor-1.5.5 | lib/asciidoctor/core_ext/1.8.7/string/limit.rb |