mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
23 lines
385 B
Ruby
23 lines
385 B
Ruby
class String
|
|
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
|
|
|
|
def is_integer?
|
|
true if Integer(self) rescue false
|
|
end
|
|
|
|
def blank?
|
|
return true if self == ''
|
|
false
|
|
end
|
|
end
|