Sha256: 1bf9c3e33b7225f40e24a0e23715e8f43fb37d908df10bc976c22efaa033c875

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

#--
# 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

        class WhoisBiz < Scanners::Base

          def parse_content
            parse_available   ||
            parse_keyvalue    ||
            skip_lastupdate   ||
            skip_fuffa        ||
            trim_newline      ||
            error!("Unexpected token")
          end


          def skip_lastupdate
            @input.skip(/>>>(.+?)<<<\n/)
          end

          def skip_fuffa
            @input.scan(/^\S(.+)\n/)
          end

          def parse_available
            if @input.scan(/^Not found: (.+)\n/)
              @ast["Domain Name"] = @input[1]
              @ast["status:available"] = true
            end
          end

          def parse_keyvalue
            if @input.scan(/(.+?):(.*?)\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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
whois-2.2.0 lib/whois/record/parser/scanners/whois.biz.rb
whois-2.1.0 lib/whois/record/parser/scanners/whois.biz.rb