class BitInByte
The BitInByte
object represents a single bit inside a byte value. He accepts a postion of himself which must be in the range of 1-8 and the actualbyte value which must be in the range of 0-255. The byte value may be decimal, hex, octal, or binary.
- author
-
Niklas Schultz
- version
-
0.1.2
- license
-
MIT
Public Class Methods
new(pos, byte)
click to toggle source
# File lib/core/bit_in_byte.rb, line 32 def initialize(pos, byte) @pos = pos @byte = byte end
Public Instance Methods
value()
click to toggle source
# File lib/core/bit_in_byte.rb, line 37 def value raise ArgumentError, 'pos must be 1-8' if @pos <= 0 || @pos > 8 raise ArgumentError, 'byte must be 0-255' if @byte < 0 || @byte > 255 position = @pos - 1 ((1 << position) & @byte) != 0 end