Class: MISP::Galaxy
Instance Attribute Summary collapse
- #description ⇒ String readonly
- #galaxy_clusters ⇒ Array<MISP::GalaxyCluster> readonly
- #id ⇒ String readonly
- #name ⇒ String readonly
- #type ⇒ String readonly
- #uuid ⇒ String readonly
- #version ⇒ String readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#get ⇒ MISP::Galaxy
Get a galaxy.
-
#initialize(**attributes) ⇒ Galaxy
constructor
A new instance of Galaxy.
-
#list ⇒ Array<Galaxy>
List galaxies.
-
#to_h ⇒ Hash
Returns a hash representation of the attribute data.
Constructor Details
#initialize(**attributes) ⇒ Galaxy
Returns a new instance of Galaxy.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/misp/galaxy.rb', line 21 def initialize(**attributes) attributes = normalize_attributes(attributes) @id = attributes.dig(:id) @uuid = attributes.dig(:uuid) @name = attributes.dig(:name) @type = attributes.dig(:type) @description = attributes.dig(:description) @version = attributes.dig(:version) @galaxy_clusters = build_plural_attribute(items: attributes.dig(:GalaxyCluster), klass: GalaxyCluster) end |
Instance Attribute Details
#description ⇒ String (readonly)
14 15 16 |
# File 'lib/misp/galaxy.rb', line 14 def description @description end |
#galaxy_clusters ⇒ Array<MISP::GalaxyCluster> (readonly)
19 20 21 |
# File 'lib/misp/galaxy.rb', line 19 def galaxy_clusters @galaxy_clusters end |
#id ⇒ String (readonly)
6 7 8 |
# File 'lib/misp/galaxy.rb', line 6 def id @id end |
#name ⇒ String (readonly)
10 11 12 |
# File 'lib/misp/galaxy.rb', line 10 def name @name end |
#type ⇒ String (readonly)
12 13 14 |
# File 'lib/misp/galaxy.rb', line 12 def type @type end |
#uuid ⇒ String (readonly)
8 9 10 |
# File 'lib/misp/galaxy.rb', line 8 def uuid @uuid end |
#version ⇒ String (readonly)
16 17 18 |
# File 'lib/misp/galaxy.rb', line 16 def version @version end |
Class Method Details
.get(id) ⇒ Object
78 79 80 |
# File 'lib/misp/galaxy.rb', line 78 def get(id) new(id: id).get end |
.list ⇒ Object
74 75 76 |
# File 'lib/misp/galaxy.rb', line 74 def list new.list end |
Instance Method Details
#get ⇒ MISP::Galaxy
Get a galaxy
69 70 71 |
# File 'lib/misp/galaxy.rb', line 69 def get _get("/galaxies/view/#{id}") { |galaxy| Galaxy.new galaxy } end |
#list ⇒ Array<Galaxy>
List galaxies
56 57 58 59 60 61 62 |
# File 'lib/misp/galaxy.rb', line 56 def list _get("/galaxies/") do |galaxies| galaxies.map do |galaxy| Galaxy.new galaxy end end end |
#to_h ⇒ Hash
Returns a hash representation of the attribute data.
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/misp/galaxy.rb', line 39 def to_h { id: id, uuid: uuid, name: name, type: type, description: description, version: version, GalaxyCluster: galaxy_clusters.map(&:to_h) }.compact end |