class String
def bin
val = self.strip
pattern = /^([+-]?)(0b)?([01]+)(.*)$/
parts = pattern.match(val)
return 0 if not parts
sign = parts[1]
num = parts[3]
eval(sign+"0b"+num)
end
end
a = "10011001".bin
b = "0b10011001".bin
c = "0B1001001".bin
d = "nothing".bin
e = "0b100121001".bin