Sha256: e2cfbc16719399e827402d6148587cd949089cbc9760bfbd128d79a1645df843

Contents?: true

Size: 888 Bytes

Versions: 6

Compression:

Stored size: 888 Bytes

Contents

module Censys
  module Search
    class Result
      #
      # Initializes the search result.
      #
      # @param [Hash{String => Object}] attributes
      #
      # @param [API] api
      #
      def initialize(attributes, api)
        @attributes = attributes
        @api        = api
      end

      #
      # The field names.
      #
      # @return [Array<String>]
      #
      def fields
        @attributes.keys
      end

      #
      # Determines whether the field exists.
      #
      # @param [String] name
      #
      # @return [Boolean]
      #
      def field?(name)
        @attributes.key?(name)
      end

      #
      # Provides arbitrary access to the result fields.
      #
      # @param [String] name
      #   The dot-separated field name.
      #
      # @return [Object]
      #
      def [](name)
        @attributes[name]
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
censu-0.1.6 lib/censys/search/result.rb
censu-0.1.5 lib/censys/search/result.rb
censu-0.1.4 lib/censys/search/result.rb
censu-0.1.3 lib/censys/search/result.rb
censu-0.1.2 lib/censys/search/result.rb
censu-0.1.1 lib/censys/search/result.rb