return recv.getRuntime().newString("HISTORY");
}
@JRubyMethod(name = "[]")
public static IRubyObject s_hist_get(IRubyObject recv, IRubyObject index) {
Ruby runtime = recv.getRuntime();
ConsoleHolder holder = getHolder(runtime);
int i = (int) index.convertToInteger().getLongValue();
try {
// TODO: MRI behavior is more complicated than that,
// there is some magic when dealing with negative indexes.
return runtime.newString((String) holder.history.getHistoryList().get(i));
} catch (IndexOutOfBoundsException ioobe) {
throw runtime.newIndexError("invalid history index: " + i);
}
}