Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/net/dns/rr/hinfo.rb
Views: 11784
# -*- coding: binary -*-1##2#3# Net::DNS::RR::HINFO4#5# $Id: HINFO.rb,v 1.4 2006/07/28 07:33:36 bluemonk Exp $6#7##89module Net10module DNS11class RR1213#------------------------------------------------------------14# RR type HINFO15#------------------------------------------------------------16class HINFO < RR17attr_reader :cpu, :os1819private2021def check_hinfo(str)22if str.strip =~ /^["'](.*?)["']\s+["'](.*?)["']$/23return $1,$224else25raise RRArgumentError, "HINFO section not valid: #{str.inspect}"26end27end2829def build_pack30@hinfo_pack = [@cpu.size].pack("C") + @cpu31@hinfo_pack += [@os.size].pack("C") + @os32@rdlength = @hinfo_pack.size33end3435def set_type36@type = Net::DNS::RR::Types.new("HINFO")37end3839def get_data40@hinfo_pack41end4243def get_inspect44"#@cpu #@os"45end4647def subclass_new_from_hash(args)48if args.has_key? :cpu and args.has_key? :os49@cpu = args[:cpu]50@os = args[:os]51else52raise RRArgumentError, ":cpu and :os fields are mandatory but missing"53end54end5556def subclass_new_from_string(str)57@cpu,@os = check_hinfo(str)58end5960def subclass_new_from_binary(data,offset)61len = data.unpack("@#{offset} C")[0]62@cpu = data[offset+1..offset+1+len]63offset += len+164len = data.unpack("@#{offset} C")[0]65@os = data[offset+1..offset+1+len]66return offset += len+167end6869end # class HINFO7071end # class RR72end # module DNS73end # module Net747576