Class: APK

Inherits:
Object
  • Object
show all
Includes:
Android
Defined in:
lib/apk.rb,
lib/apk/version.rb

Constant Summary collapse

VERSION =
'0.1.3'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(apk_path) ⇒ APK

Returns a new instance of APK.



9
10
11
12
13
# File 'lib/apk.rb', line 9

def initialize(apk_path)
  @apk = apk_path
  @aapt = AAPT.new(@apk)
  @resource = Resource.new(@apk)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



21
22
23
# File 'lib/apk.rb', line 21

def method_missing(method, *args, &block)
  (@dump ||= @aapt.dump)[method]
end

Instance Attribute Details

#aaptObject (readonly)

Returns the value of attribute aapt.



7
8
9
# File 'lib/apk.rb', line 7

def aapt
  @aapt
end

#apkObject (readonly)

Returns the value of attribute apk.



7
8
9
# File 'lib/apk.rb', line 7

def apk
  @apk
end

#dumpObject (readonly)

Returns the value of attribute dump.



7
8
9
# File 'lib/apk.rb', line 7

def dump
  @dump
end

#resourceObject (readonly)

Returns the value of attribute resource.



7
8
9
# File 'lib/apk.rb', line 7

def resource
  @resource
end

Instance Method Details

#drawable(name = "icon.png") ⇒ Object



15
16
17
18
19
# File 'lib/apk.rb', line 15

def drawable(name = "icon.png")
  dst = "/tmp/ruby-apk-#{Time.now.to_i}"
  @resource.extract(name, dst)
  dst
end