Sha256: 62d477671e88fa078e665bdb1514bf31c63999a07aa198151a04390cfe90b658

Contents?: true

Size: 600 Bytes

Versions: 1

Compression:

Stored size: 600 Bytes

Contents

# frozen_string_literal: true
# typed: true

# rubocop:disable Style/Documentation

class Integer
  # rubocop:enable Style/Documentation
  extend T::Sig
  # Aligns the integer to the nearest multiple of the alignment.
  # @param alignment [Integer] the alignment
  # @return [Integer] the aligned integer
  sig { params(alignment: T.nilable(Integer)).returns(Integer) }
  def align(alignment = nil)
    alignment ||= 4

    return self if T.must(alignment) < 2

    alignment = T.must(alignment) - 1

    if (self & alignment).zero?
      self
    else
      (self | alignment) + 1
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mootool-0.2.8 lib/mootool/core_extensions.rb