# File lib/snmp/varbind.rb, line 249 def decode(value_data) IpAddress.new(value_data, false) end
Create an IpAddress object. The constructor accepts either a raw four-octet string or a formatted string of integers separated by dots (i.e. “10.1.2.3”). Validation of the format can be disabled by setting the ‘validate’ flag to false.
# File lib/snmp/varbind.rb, line 264 def initialize(value_data, validate=true) ip = value_data.to_str if (validate) if ip.length > 4 ip = parse_string(ip) elsif ip.length != 4 raise InvalidIpAddress, "Expected 4 octets or formatted string, got #{value_data.inspect}" end end @value = ip end
# File lib/snmp/varbind.rb, line 298 def ==(other) if other.respond_to? :to_str return @value.eql?(other.to_str) else return false end end
# File lib/snmp/varbind.rb, line 254 def asn1_type "IpAddress" end
# File lib/snmp/varbind.rb, line 314 def encode encode_tlv(IpAddress_TAG, @value) end
# File lib/snmp/varbind.rb, line 306 def eql?(other) self == other end
# File lib/snmp/varbind.rb, line 292 def to_oid oid = ObjectId.new @value.each_byte { |b| oid << b } oid end
Returns a formatted, dot-separated string representing this IpAddress.
# File lib/snmp/varbind.rb, line 286 def to_s octets = [] @value.each_byte { |b| octets << b.to_s } octets.join('.') end
Returns a raw four-octet string representing this IpAddress.
# File lib/snmp/varbind.rb, line 279 def to_str @value.dup end
Generated with the Darkfish Rdoc Generator 2.