Class: MobilePronto::Abbreviation
- Inherits:
-
Object
- Object
- MobilePronto::Abbreviation
- Defined in:
- lib/mobilepronto/abbreviation.rb
Class Method Summary collapse
Class Method Details
.abbr(name, limit = nil) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/mobilepronto/abbreviation.rb', line 6 def abbr(name, limit = nil) limit ||= name.size words = name.to_s.split(' ') name = [words.shift] while(words.size > 0 && (name + words).join(' ').size > limit) do name << "#{words.shift[0.1]}." end name.concat(words).join(' ') end |