Sha256: ce71ae01e38c8fc240181b7e50391b4ea2a4b55af71aa91eac0e9f449b0849e3

Contents?: true

Size: 885 Bytes

Versions: 1

Compression:

Stored size: 885 Bytes

Contents

# frozen_string_literal: true

module MISP
  class Server < Base
    # @return [String]
    attr_reader :id
    # @return [String]
    attr_reader :url
    # @return [String]
    attr_reader :name

    def initialize(**attributes)
      attributes = normalize_attributes(attributes)

      @id = attributes.dig(:id)
      @url = attributes.dig(:url)
      @name = attributes.dig(:name)
    end

    #
    # Returns a hash representation of the attribute data.
    #
    # @return [Hash]
    #
    def to_h
      {
        id: id,
        url: url,
        name: name,
      }.compact
    end

    #
    # List servers
    #
    # @return [Array<MISP::Server>]
    #
    def list
      _get("/servers/") do |servers|
        servers.map do |server|
          Server.new server
        end
      end
    end

    class << self
      def list
        new.list
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
misp-0.1.1 lib/misp/server.rb