Skip to content

Commit 3984381

Browse files
authored
Merge pull request #867 from p8/refactor/remove-string-encode-conditional
Remove String#encode conditional required by Ruby < 2.6
2 parents 8d6edeb + dff675a commit 3984381

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

lib/thor/shell/table_printer.rb

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -102,33 +102,17 @@ def print_border_separator
102102

103103
def truncate(string)
104104
return string unless @truncate
105-
as_unicode do
106-
chars = string.chars.to_a
107-
if chars.length <= @truncate
108-
chars.join
109-
else
110-
chars[0, @truncate - 3 - @indent].join + "..."
111-
end
105+
chars = string.chars.to_a
106+
if chars.length <= @truncate
107+
chars.join
108+
else
109+
chars[0, @truncate - 3 - @indent].join + "..."
112110
end
113111
end
114112

115113
def indentation
116114
" " * @indent
117115
end
118-
119-
if "".respond_to?(:encode)
120-
def as_unicode
121-
yield
122-
end
123-
else
124-
def as_unicode
125-
old = $KCODE # rubocop:disable Style/GlobalVars
126-
$KCODE = "U" # rubocop:disable Style/GlobalVars
127-
yield
128-
ensure
129-
$KCODE = old # rubocop:disable Style/GlobalVars
130-
end
131-
end
132116
end
133117
end
134118
end

0 commit comments

Comments
 (0)