Sha256: 2d0913538387c4573959c7653ac6431e353d4f0cc767b3f2782a369774dfefbb

Contents?: true

Size: 377 Bytes

Versions: 24

Compression:

Stored size: 377 Bytes

Contents

module MonkeyPatch
  module Integer
    # Defines Integer#nbit? methods.
    module Ranges
      def unsigned_8bit?
        _within_range? 8
      end

      def unsigned_16bit?
        _within_range? 16
      end

      def unsigned_32bit?
        _within_range? 32
      end

      def _within_range?(nbit)
        (0 <= self) && (self < 2**nbit)
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
pio-0.23.1 lib/pio/monkey_patch/integer/ranges.rb
pio-0.23.0 lib/pio/monkey_patch/integer/ranges.rb
pio-0.22.0 lib/pio/monkey_patch/integer/ranges.rb
pio-0.21.1 lib/pio/monkey_patch/integer/ranges.rb
pio-0.21.0 lib/pio/monkey_patch/integer/ranges.rb
pio-0.20.1 lib/pio/monkey_patch/integer/ranges.rb
pio-0.20.0 lib/pio/monkey_patch/integer/ranges.rb
pio-0.19.0 lib/pio/monkey_patch/integer/ranges.rb
pio-0.18.2 lib/pio/monkey_patch/integer/ranges.rb
pio-0.18.1 lib/pio/monkey_patch/integer/ranges.rb
pio-0.18.0 lib/pio/monkey_patch/integer/ranges.rb
pio-0.17.0 lib/pio/monkey_patch/integer/ranges.rb
pio-0.16.0 lib/pio/monkey_patch/integer/ranges.rb
pio-0.15.2 lib/pio/monkey_patch/integer/ranges.rb
pio-0.15.1 lib/pio/monkey_patch/integer/ranges.rb
pio-0.15.0 lib/pio/monkey_patch/integer/ranges.rb
pio-0.14.0 lib/pio/monkey_patch/integer/ranges.rb
pio-0.13.0 lib/pio/monkey_patch/integer/ranges.rb
pio-0.12.0 lib/pio/monkey_patch/integer/ranges.rb
pio-0.11.2 lib/pio/monkey_patch/integer/ranges.rb