Skip to content

Commit

Permalink
Add Integer#ceildiv (3.2)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed Mar 7, 2023
1 parent 2527974 commit 1f74308
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ itself, JRuby and Rubinius.

- `shift` (with correct behavior when empty)

#### Integer

- `ceildiv`

## Ruby 3.1 backports

#### Array
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ IGNORE = %w[
3.1.0/struct/keyword_init
3.2.0/enumerator/product
3.2.0/hash/shift
3.2.0/integer/ceildiv
]

CLASS_MAP = Hash.new{|k, v| k[v] = v}.merge!(
Expand Down
3 changes: 3 additions & 0 deletions lib/backports/3.2.0/integer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require 'backports/tools/require_relative_dir'

Backports.require_relative_dir
7 changes: 7 additions & 0 deletions lib/backports/3.2.0/integer/ceildiv.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
unless Integer.method_defined? :ceildiv
class Integer
def ceildiv(arg)
fdiv(arg).ceil
end
end
end

0 comments on commit 1f74308

Please sign in to comment.