Sha256: 220a2b0706b25e17e196fef3f70ffc37ae0bb8544c3963908174598a83465c21

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

#--
# Ruby Whois
#
# An intelligent pure Ruby WHOIS client and parser.
#
# Copyright (c) 2009-2017 Simone Carletti <weppos@weppos.net>
#++


module Whois
  class Record

    # A single {Whois::Record} fragment. For instance,
    # in case of *thin server*, a {Whois::Record} can be composed by
    # one or more parts corresponding to all responses
    # returned by the WHOIS servers.
    #
    # A part is composed by a +body+ and a +host+.
    #
    # @attr [String] body The body containing the WHOIS output.
    # @attr [String] host The host which returned the body.
    #
    class Part < Struct.new(:body, :host)

      def initialize(*args)
        if args.first.is_a? Hash
          initialize_with_hash(args.first)
        elsif args.size == 0
          super
        else
          raise ArgumentError
        end
        yield(self) if block_given?
      end

      private

      def initialize_with_hash(attributes = {})
        attributes.each do |key, value|
          self[key] = value
        end
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
whois-4.0.5 lib/whois/record/part.rb
whois-4.0.4 lib/whois/record/part.rb
whois-4.0.3 lib/whois/record/part.rb
whois-4.0.2 lib/whois/record/part.rb