Sha256: 972297dff1c8e927248b722df8045af3be807505eafc408bb4fbdce0d9603485

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'
require 'eac_ruby_utils/custom_format'
require 'ehbrs/vg/wii/wit/parsers/dump'
require 'ehbrs/vg/wii/wit/path'
require 'pathname'

module Ehbrs
  module Vg
    module Wii
      class GameFile < ::Pathname
        enable_simple_cache

        FORMAT = ::EacRubyUtils::CustomFormat.new(
          b: :basename,
          d: :dirname,
          e: :extname,
          i: :id6,
          n: :disc_name,
          t: :database_title,
          T: :disc_type
        )

        def database_title
          properties.fetch('DB title')
        end

        def disc_name
          properties.fetch('Disc name')
        end

        def disc_type
          properties.fetch('File & disc type/type')
        end

        def format(string)
          FORMAT.format(string).with(self)
        end

        def id6
          properties.fetch('Disc & part IDs/disc')
        end

        def valid?
          properties.present?
        end

        def wit_path
          ::Ehbrs::Vg::Wii::Wit::Path.new(disc_type, self)
        end

        private

        def properties_uncached
          r = ::Ehbrs::Executables.wit.command.append(['dump', to_s]).execute
          return nil unless r.fetch(:exit_code).zero?

          ::Ehbrs::Vg::Wii::Wit::Parsers::Dump.new(r.fetch(:stdout)).properties
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ehbrs-tools-0.7.0 lib/ehbrs/vg/wii/game_file.rb
ehbrs-tools-0.6.0 lib/ehbrs/vg/wii/game_file.rb
ehbrs-tools-0.5.0 lib/ehbrs/vg/wii/game_file.rb