class Arkrb::Mods

Public Class Methods

new() click to toggle source
# File lib/arkrb/server/mods.rb, line 5
def initialize
  @mod_list = []
end

Public Instance Methods

add(id) click to toggle source

@return [Arkrb::Mod, Exception]

# File lib/arkrb/server/mods.rb, line 20
def add(id)
  begin
    find_by_id(id)
    raise Arkrb::Error::ModAlreadyExists, "Mod #{id} already exists in the mod list!"
  rescue Arkrb::Error::ModIDNotFound
    mod = Arkrb::Mod.new(id)
    @mod_list << mod
    mod
  end
end
delete(id) click to toggle source

@return [True, Exception]

# File lib/arkrb/server/mods.rb, line 32
def delete(id)
  find_by_id(id)
  @mod_list.delete_if {|m| m.id == id}
  true
end
find_by_id(id) click to toggle source

@return [Arkrb::Mod, Exception]

# File lib/arkrb/server/mods.rb, line 10
def find_by_id(id)
  mod = @mod_list.find {|m| m.id == id}
  if mod.nil?
    raise Arkrb::Error::ModIDNotFound, "Mod #{id} was not found in the mod list!"
  else
    mod
  end
end
to_h() click to toggle source

@return [Hash]

# File lib/arkrb/server/mods.rb, line 39
def to_h
  @mod_list.map {|m| m.to_h}
end
Also aliased as: to_hash
to_hash()
Alias for: to_h