lib/icarus/mod/tools/modinfo.rb in Icarus-Mod-Tools-1.9.0 vs lib/icarus/mod/tools/modinfo.rb in Icarus-Mod-Tools-2.0
- old
+ new
@@ -5,10 +5,28 @@
module Icarus
module Mod
module Tools
# Sync methods
class Modinfo < Baseinfo
- HASHKEYS = %i[name author version compatibility description long_description fileType fileURL imageURL readmeURL].freeze
+ HASHKEYS = %i[name author version compatibility description long_description files fileType fileURL imageURL readmeURL].freeze
+
+ def to_h
+ HASHKEYS.each_with_object({}) do |key, hash|
+ next if key == :files && @data[:files].nil?
+ next if %i[fileType fileURL].include?(key.to_sym) && !@data[:files].nil?
+ next if key == :long_description && @data[:long_description].nil?
+
+ hash[key] = @data[key]
+ end
+ end
+
+ def file_types
+ files&.keys || [@data[:fileType] || "pak"]
+ end
+
+ def file_urls
+ files&.values || [@data[:fileURL]].compact
+ end
# rubocop:disable Naming/MethodName
def fileType
@data[:fileType] || "pak"
end