Class: Android::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/android/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(apk_path) ⇒ Resource

Returns a new instance of Resource.



8
9
10
# File 'lib/android/resource.rb', line 8

def initialize(apk_path)
  @apk = apk_path
end

Instance Attribute Details

#apkObject (readonly)

Returns the value of attribute apk.



6
7
8
# File 'lib/android/resource.rb', line 6

def apk
  @apk
end

Instance Method Details

#extract(res, dst) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/android/resource.rb', line 12

def extract(res, dst)
  Zip::ZipFile.open(@apk) do |zipfile|
    %w[xxhdpi xhdpi hdpi mdpi ldpi].each do |s|
      break unless zipfile.each do |file|
        if "res/drawable-#{s}/#{res}" == file.name
          zipfile.extract(file, dst)
          break
        end
      end
    end
  end
end