instance method
limit
Ruby on Rails 4.1.16
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 107
def limit(limit)
slice(0...translate_offset(limit))
end
Defined in activesupport/lib/active_support/multibyte/chars.rb line 107
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Multibyte::Chars