class String

@private

Public Instance Methods

all?(&bl) click to toggle source
# File lib/xrbp/core_ext.rb, line 33
def all?(&bl)
  each_char { |c| return false unless bl.call(c) }
  return true
end
chunk(size) click to toggle source

scan(regex) will not work as we need to process binary strings (n's seem to trip scan up)

# File lib/xrbp/core_ext.rb, line 45
def chunk(size)
  ((self.length + size - 1) / size).times.collect { |i| self[i * size, size] }
end
to_bn() click to toggle source

return bignum corresponding to string

# File lib/xrbp/core_ext.rb, line 29
def to_bn
  bytes.inject(0) { |bn, b| (bn << 8) | b }
end
zero?() click to toggle source
# File lib/xrbp/core_ext.rb, line 38
def zero?
  return self == "\0" if size == 1
  all? { |c| c.zero? }
end