Ruby 4.1 リファレンスマニュアル

instance method Integer#ceildiv

ceildiv(other) -> IntegerRuby 3.2 から[permalink][rdoc][edit]

selfother で割り、その(剰余を考えない)商を整数に切り上げたものを返します。すなわち、selfother で割った商を q とすると、q 以上で最小の整数を返します。

[PARAM] other:
self を割る数を指定します。
p 3.ceildiv(3)  # => 1
p 4.ceildiv(3)  # => 2
p 5.ceildiv(3)  # => 2
p 3.ceildiv(1.2)  # => 3
p -5.ceildiv(3) # => -1
p -5.ceildiv(-3)  # => 2