Skip to content

Commit 60d7a03

Browse files
committed
ext: string
1 parent e279dfa commit 60d7a03

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/ext/string.cr

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# -----------------------------------------------------------------------
2+
# This file is part of MoonScript
3+
#
4+
# MoonSript is free software: you can redistribute it and/or modify
5+
# it under the terms of the GNU General Public License as published by
6+
# the Free Software Foundation, either version 3 of the License, or
7+
# (at your option) any later version.
8+
#
9+
# MoonSript is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with MoonSript. If not, see <https://www.gnu.org/licenses/>.
16+
#
17+
# Copyright (C) 2025 Krisna Pranav, MoonScript Developers
18+
# -----------------------------------------------------------------------
19+
20+
class String
21+
def uncolorize: String
22+
end
23+
24+
def last? : Char?
25+
self[-1]?
26+
end
27+
28+
def indent(spaces: Int32 = 2) : String
29+
lines.join('\n') do |line|
30+
line.empty? ? line : ("" * spaces) + line
31+
end
32+
end
33+
end

0 commit comments

Comments
 (0)