module NETSNMP::StringExtensions
Public Instance Methods
match?(*args)
click to toggle source
# File lib/netsnmp/extensions.rb, line 18 def match?(*args) !match(*args).nil? end
unpack1(format)
click to toggle source
# File lib/netsnmp/extensions.rb, line 24 def unpack1(format) unpack(format).first end
xor(other)
click to toggle source
Bitwise XOR operator for the String class
# File lib/netsnmp.rb, line 21 def xor(other) b1 = unpack("C*") return b1 unless other b2 = other.unpack("C*") longest = [b1.length, b2.length].max b1 = [0] * (longest - b1.length) + b1 b2 = [0] * (longest - b2.length) + b2 b1.zip(b2).map { |a, b| a ^ b }.pack("C*") end