Class: Headdesk::Apk::Class
- Inherits:
-
Object
- Object
- Headdesk::Apk::Class
- Defined in:
- lib/headdesk/apk/class.rb
Overview
A Smali bytecode class
Class Method Summary collapse
-
.path_for(decl) ⇒ Object
Formats: android/content/Context android.content.Context.
Instance Method Summary collapse
- #field(name) ⇒ Object
- #field?(name) ⇒ Boolean
-
#initialize(smali_file) ⇒ Class
constructor
A new instance of Class.
- #method(name) ⇒ Object
- #method?(name) ⇒ Boolean
Constructor Details
#initialize(smali_file) ⇒ Class
Returns a new instance of Class.
19 20 21 |
# File 'lib/headdesk/apk/class.rb', line 19 def initialize(smali_file) @smali = File.read(smali_file) end |
Class Method Details
.path_for(decl) ⇒ Object
Formats:
android/content/Context
android.content.Context
15 16 17 |
# File 'lib/headdesk/apk/class.rb', line 15 def self.path_for(decl) File.join(*decl.split(%r{[\/,\.]})) end |
Instance Method Details
#field(name) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/headdesk/apk/class.rb', line 38 def field(name) matchdata = /^\.field .* #{name}.* = "(.*)"$/.match(@smali) return nil unless matchdata Field.new(matchdata) end |
#field?(name) ⇒ Boolean
34 35 36 |
# File 'lib/headdesk/apk/class.rb', line 34 def field?(name) field(name) != false end |
#method(name) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/headdesk/apk/class.rb', line 27 def method(name) matchdata = /(^\.method .* #{name}.*$[\s\S]*?\.end method)/.match(@smali) return nil unless matchdata Method.new(matchdata) end |
#method?(name) ⇒ Boolean
23 24 25 |
# File 'lib/headdesk/apk/class.rb', line 23 def method?(name) method(name) != false end |