instance method
limit
Ruby on Rails 7.1.6
Since v3.0.20Signature
limit(limit)
Limits the byte size of the string to a number of bytes without breaking characters. Usable when the storage for a string is limited for some reason.
'こんにちは'.mb_chars.limit(7).to_s # => "こん"
Parameters
-
limitreq
Source
# File activesupport/lib/active_support/multibyte/chars.rb, line 115
def limit(limit)
chars(@wrapped_string.truncate_bytes(limit, omission: nil))
end
Defined in activesupport/lib/active_support/multibyte/chars.rb line 115
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Multibyte::Chars