neocities/ext/string.rb
2014-11-20 04:44:44 -08:00

18 lines
No EOL
311 B
Ruby

class String
def empty?
strip == '' ? true : false
end
def shorten(length, usedots=true)
if usedots
return self if self.length < length
"#{self[0..length-3]}..."
else
self[0..length]
end
end
def unindent
gsub /^#{scan(/^\s*/).min_by{|l|l.length}}/, ""
end
end