lib/misp/galaxy.rb in misp-0.1.0 vs lib/misp/galaxy.rb in misp-0.1.1
- old
+ new
@@ -1,16 +1,23 @@
# frozen_string_literal: true
module MISP
class Galaxy < Base
+ # @return [String]
attr_reader :id
+ # @return [String]
attr_reader :uuid
+ # @return [String]
attr_reader :name
+ # @return [String]
attr_reader :type
+ # @return [String]
attr_reader :description
+ # @return [String]
attr_reader :version
+ # @return [Array<MISP::GalaxyCluster>]
attr_reader :galaxy_clusters
def initialize(**attributes)
attributes = normalize_attributes(attributes)
@@ -22,10 +29,15 @@
@version = attributes.dig(:version)
@galaxy_clusters = build_plural_attribute(items: attributes.dig(:GalaxyCluster), klass: GalaxyCluster)
end
+ #
+ # Returns a hash representation of the attribute data.
+ #
+ # @return [Hash]
+ #
def to_h
{
id: id,
uuid: uuid,
name: name,
@@ -34,26 +46,38 @@
version: version,
GalaxyCluster: galaxy_clusters.map(&:to_h)
}.compact
end
+ #
+ # List galaxies
+ #
+ # @return [Array<Galaxy>]
+ #
def list
_get("/galaxies/") do |galaxies|
galaxies.map do |galaxy|
- Galaxy.new symbolize_keys(galaxy)
+ Galaxy.new galaxy
end
end
end
- def self.list
- new.list
- end
-
+ #
+ # Get a galaxy
+ #
+ # @return [MISP::Galaxy]
+ #
def get
- _get("/galaxies/view/#{id}") { |galaxy| Galaxy.new symbolize_keys(galaxy) }
+ _get("/galaxies/view/#{id}") { |galaxy| Galaxy.new galaxy }
end
- def self.get(id)
- new(id: id).get
+ class << self
+ def list
+ new.list
+ end
+
+ def get(id)
+ new(id: id).get
+ end
end
end
end