Sha256: f0919ebf9b5992333a9fd9fab5bea9e799c8c4456e1f8c8fb870705eadf11df2

Contents?: true

Size: 1004 Bytes

Versions: 2

Compression:

Stored size: 1004 Bytes

Contents

# frozen_string_literal: true

require "tools/baseinfo"

module Icarus
  module Mod
    module Tools
      # Sync methods
      class Modinfo < Baseinfo
        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
        # rubocop:enable Naming/MethodName
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
Icarus-Mod-Tools-2.0.1 lib/icarus/mod/tools/modinfo.rb
Icarus-Mod-Tools-2.0 lib/icarus/mod/tools/modinfo.rb