Class: D3MPQ::Command::Extract

Inherits:
Object
  • Object
show all
Defined in:
lib/d3_mpq/commands/extract.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Extract

Returns a new instance of Extract.



5
6
7
8
9
10
11
12
# File 'lib/d3_mpq/commands/extract.rb', line 5

def initialize(options = {})
  @options = options
  @options[:mpq_path] += "/" unless @options[:mpq_path].end_with?("/")
  logger "Extracting MPQ"
  cmd = "#{cd} && smpq -ef #{mpq} #{patch}"
  logger "Performing: #{cmd}"
  logger `#{cmd}`
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/d3_mpq/commands/extract.rb', line 3

def options
  @options
end

Class Method Details

.allObject



15
16
17
# File 'lib/d3_mpq/commands/extract.rb', line 15

def all
  known_mpqs.each { |mpq| self.new(mpq) }
end

.known_mpqsObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/d3_mpq/commands/extract.rb', line 19

def known_mpqs
  [
    "ClientData",
    "GameBalance",
    "enUS_Audio",
    "enUS_Cutscene",
    "enUS_Text",
    "HLSLShaders",
    "Sound",
    "Texture"
  ]
end

Instance Method Details

#cdObject



33
34
35
# File 'lib/d3_mpq/commands/extract.rb', line 33

def cd
  "cd #{options[:extract_path]}"
end

#logger(msg) ⇒ Object



49
50
51
# File 'lib/d3_mpq/commands/extract.rb', line 49

def logger(msg)
  puts msg
end

#mpqObject



41
42
43
# File 'lib/d3_mpq/commands/extract.rb', line 41

def mpq
  "#{mpq_path}#{options[:mpq]}.mpq"
end

#mpq_pathObject



45
46
47
# File 'lib/d3_mpq/commands/extract.rb', line 45

def mpq_path
  "../#{options[:mpq_path]}"
end

#patchObject



37
38
39
# File 'lib/d3_mpq/commands/extract.rb', line 37

def patch
  "-p #{mpq_path}base/* #{mpq_path}#{options[:locale]}/* #{mpq_path}Win/*"
end