Method: NicInfo::Main#create_resource_url
- Defined in:
- lib/nicinfo/nicinfo_main.rb
#create_resource_url(args, queryType) ⇒ Object
Creates a query type
939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 |
# File 'lib/nicinfo/nicinfo_main.rb', line 939 def create_resource_url(args, queryType) path = "" case queryType when QueryType::BY_IP4_ADDR path << "ip/" << args[0] when QueryType::BY_IP6_ADDR path << "ip/" << args[0] when QueryType::BY_IP4_CIDR path << "ip/" << args[0] when QueryType::BY_IP6_CIDR path << "ip/" << args[0] when QueryType::BY_AS_NUMBER path << "autnum/" << args[0] when QueryType::BY_NAMESERVER path << "nameserver/" << args[0] when QueryType::BY_DOMAIN path << "domain/" << args[0] when QueryType::BY_RESULT tree = @config.load_as_yaml(NicInfo::ARININFO_LASTTREE_YAML) path = tree.find_rest_ref(args[0]) raise ArgumentError.new("Unable to find result for " + args[0]) unless path when QueryType::BY_ENTITY_HANDLE path << "entity/" << URI.escape( args[ 0 ] ) when QueryType::SRCH_ENTITY_BY_NAME case args.length when 1 path << "entities?fn=" << URI.escape( args[ 0 ] ) when 2 path << "entities?fn=" << URI.escape( args[ 0 ] + " " + args[ 1 ] ) when 3 path << "entities?fn=" << URI.escape( args[ 0 ] + " " + args[ 1 ] + " " + args[ 2 ] ) end when QueryType::SRCH_DOMAIN_BY_NAME path << "domains?name=" << args[ 0 ] when QueryType::SRCH_DOMAIN_BY_NSNAME path << "domains?nsLdhName=" << args[ 0 ] when QueryType::SRCH_DOMAIN_BY_NSIP path << "domains?nsIp=" << args[ 0 ] when QueryType::SRCH_NS_BY_NAME path << "nameservers?name=" << args[ 0 ] when QueryType::SRCH_NS_BY_IP path << "nameservers?ip=" << args[ 0 ] when QueryType::BY_SERVER_HELP path << "help" else raise ArgumentError.new("Unable to create a resource URL for " + queryType) end return path end |