Class: StarCitizen::Pak
- Inherits:
-
Object
- Object
- StarCitizen::Pak
- Defined in:
- lib/starcitizen/pak.rb
Overview
A .pak file. Located in /CitizenClient/Data
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#extract(path, **kwargs) ⇒ Object
Extract a file from the package.
-
#initialize(name) ⇒ Pak
constructor
A new instance of Pak.
Constructor Details
#initialize(name) ⇒ Pak
Returns a new instance of Pak.
15 16 17 18 |
# File 'lib/starcitizen/pak.rb', line 15 def initialize name @name = name @path = "#{StarCitizen::Config.game_path}/CitizenClient/Data/#{name}.pak" end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/starcitizen/pak.rb', line 12 def name @name end |
Instance Method Details
#extract(path, **kwargs) ⇒ Object
Extract a file from the package.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/starcitizen/pak.rb', line 26 def extract path, **kwargs output_dir = kwargs.fetch :output_dir, '.' Zip::File.open(@path) do |files| pak_file = files.glob(path).first FileUtils.mkdir_p output_dir FileUtils.chdir output_dir do filename = path.split('/').last File.delete filename if File.exists? filename pak_file.extract pak_file.name.split('/').last end end end |