意味不明だが、つまりはそういうこと。既にそういう方法はあるのだろうが、わからんので自前実装。
class String def is_int? return self == self.to_i.to_s end end p "68.03".is_int? # false p "4".is_int? # true p "hoge".is_int? # false p "-301".is_int? # true
こんな感じ。文字列を整数に変換し、さらに文字列に変換し直して、元々の文字列と一致すれば整数だろうというもの。