Sha256: 8b5e40b70689c9e93a094e2681223919ffbc17a140a28e16fc12ecf0670f973d

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

#--
# Ruby Whois
#
# An intelligent pure Ruby WHOIS client and parser.
#
# Copyright (c) 2009-2024 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.
    #
    Part = Struct.new(:body, :host) do
      def initialize(*args)
        if args.first.is_a? Hash
          initialize_with_hash(args.first)
        elsif args.empty?
          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

2 entries across 2 versions & 1 rubygems

Version Path
whois-6.0.1 lib/whois/record/part.rb
whois-6.0.0 lib/whois/record/part.rb