Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 55 lines (43 sloc) 1.153 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
#--
# Ruby Whois
#
# An intelligent pure Ruby WHOIS client and parser.
#
# Copyright (c) 2009-2011 Simone Carletti <weppos@weppos.net>
#++


require 'whois/record/parser/scanners/base'


module Whois
  class Record
    class Parser
      module Scanners

        # Scanner for the whois.registry.qa server response.
        #
        # @since 2.1.0
        class WhoisRegistryQa < Scanners::Base

          def parse_content
            parse_available ||
            parse_keyvalue_spaced ||

            trim_empty_line ||
            error!("Unexpected token")
          end

          def parse_available
            if @input.scan(/^No Data Found\n/)
              @ast["status:available"] = true
            end
          end

          def parse_keyvalue_spaced
            if @input.scan(/(.+?):\s+(.*?)\n/)
              key, value = @input[1].strip, @input[2].strip
              if @ast[key].nil?
                @ast[key] = value
              else
                @ast[key].is_a?(Array) || @ast[key] = [@ast[key]]
                @ast[key] << value
              end
            end
          end

        end

      end
    end
  end
end
Something went wrong with that request. Please try again.