String#[] (Ruby 3.4 リファレンスマニュアル)

nth 番目の文字を返します。 nth が負の場合は文字列の末尾から数えます。 つまり、 self.size + nth 番目の文字を返します。