Sha256: 118b28c3fc32806bf8bf3aaea12bd20b16c10d3f8d5036c88a95519396d552fc

Contents?: true

Size: 1.33 KB

Versions: 8

Compression:

Stored size: 1.33 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 Afilias < Scanners::Base

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

          def parse_available
            if @input.scan(/^NOT FOUND\n/)
              @ast["status-available"] = true
            end
          end

          def parse_disclaimer
            if @input.match?(/^Access to/)
              lines = []
              while @input.scan(/^(.+)\n/)
                lines << @input[1].strip
              end
              @ast["property-disclaimer"] = lines.join(" ")
            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

8 entries across 8 versions & 1 rubygems

Version Path
whois-2.0.7 lib/whois/record/parser/scanners/afilias.rb
whois-2.0.6 lib/whois/record/parser/scanners/afilias.rb
whois-2.0.5 lib/whois/record/parser/scanners/afilias.rb
whois-2.0.4 lib/whois/record/parser/scanners/afilias.rb
whois-2.0.3 lib/whois/record/parser/scanners/afilias.rb
whois-2.0.2 lib/whois/record/parser/scanners/afilias.rb
whois-2.0.1 lib/whois/record/parser/scanners/afilias.rb
whois-2.0.0 lib/whois/record/parser/scanners/afilias.rb