Class: Abra::APK
- Inherits:
-
Object
- Object
- Abra::APK
- Defined in:
- lib/apk.rb
Instance Attribute Summary collapse
-
#api_level ⇒ Object
readonly
Returns the value of attribute api_level.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#package ⇒ Object
readonly
Returns the value of attribute package.
-
#version_code ⇒ Object
readonly
Returns the value of attribute version_code.
-
#version_name ⇒ Object
readonly
Returns the value of attribute version_name.
Instance Method Summary collapse
- #icon_file ⇒ Object
-
#initialize(apk_path) ⇒ APK
constructor
A new instance of APK.
- #sdk_version ⇒ Object
Constructor Details
#initialize(apk_path) ⇒ APK
Returns a new instance of APK.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/apk.rb', line 11 def initialize(apk_path) @apk = apk_path attrs = Abra::AAPT.dump_badging(@apk) @package = attrs[:package] @version_name = attrs[:version_name] @version_code = attrs[:version_code].to_i @label = attrs[:label] @icon = attrs[:icon] @api_level = attrs[:api_level].to_i @resource = Resource.new(@apk) end |
Instance Attribute Details
#api_level ⇒ Object (readonly)
Returns the value of attribute api_level.
9 10 11 |
# File 'lib/apk.rb', line 9 def api_level @api_level end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
9 10 11 |
# File 'lib/apk.rb', line 9 def icon @icon end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
9 10 11 |
# File 'lib/apk.rb', line 9 def label @label end |
#package ⇒ Object (readonly)
Returns the value of attribute package.
9 10 11 |
# File 'lib/apk.rb', line 9 def package @package end |
#version_code ⇒ Object (readonly)
Returns the value of attribute version_code.
9 10 11 |
# File 'lib/apk.rb', line 9 def version_code @version_code end |
#version_name ⇒ Object (readonly)
Returns the value of attribute version_name.
9 10 11 |
# File 'lib/apk.rb', line 9 def version_name @version_name end |
Instance Method Details
#icon_file ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/apk.rb', line 23 def icon_file if self.icon dst = "/tmp/abra-#{Time.now.to_i.to_s}-#{Process.pid.to_s}-#{("%04d" % rand(9999))}" @resource.extract(self.icon, dst) File.read(dst) File.delete(dst) else nil end end |
#sdk_version ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/apk.rb', line 34 def sdk_version case self.api_level when 8 '2.2' when 9..10 '2.3' when 11..13 '3.0' when 14..15 '4.0' when 16 '4.1' when 17 '4.2' end end |