20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/bitwise.rb', line 20
def bit?(bit)
if bit == 7
value = 0 if self & 128 == 0
value = 1 if self & 128 != 0
elsif bit == 6
value = 0 if self & 64 == 0
value = 1 if self & 64 != 0
elsif bit == 5
value = 0 if self & 32 == 0
value = 1 if self & 32 != 0
elsif bit == 4
value = 0 if self & 16 == 0
value = 1 if self & 16 != 0
elsif bit == 3
value = 0 if self & 8 == 0
value = 1 if self & 8 != 0
elsif bit == 2
value = 0 if self & 4 == 0
value = 1 if self & 4 != 0
elsif bit == 1
value = 0 if self & 2 == 0
value = 1 if self & 2 != 0
elsif bit == 0
value = 0 if self & 1 == 0
value = 1 if self & 1 != 0
end
return value
end
|