Class: Android::Resource
- Inherits:
-
Object
- Object
- Android::Resource
- Defined in:
- lib/android/resource.rb
Overview
based on Android OS source code /frameworks/base/include/utils/ResourceTypes.h
Defined Under Namespace
Classes: Chunk, ChunkHeader, ResStringPool, ResTableConfig, ResTableEntry, ResTableHeader, ResTableMap, ResTableMapEntry, ResTablePackage, ResTableType, ResTableTypeSpec, ResValue
Instance Attribute Summary collapse
-
#packages ⇒ Object
readonly
Returns the value of attribute packages.
Instance Method Summary collapse
-
#find(rsc_id, opt = {}) ⇒ Object
This method only support string resource for now.
- #first_pkg ⇒ Object
-
#initialize(data) ⇒ Resource
constructor
A new instance of Resource.
-
#package_count ⇒ Fixnum
Number of packages.
-
#res_hex_id(readable_id) ⇒ String
convert readable resource id to hex id.
-
#res_readable_id(hex_id) ⇒ String
Readable resource id (‘@string/key’).
-
#strings ⇒ Array<String>
All strings defined in arsc.
Constructor Details
#initialize(data) ⇒ Resource
Returns a new instance of Resource.
451 452 453 454 455 |
# File 'lib/android/resource.rb', line 451 def initialize(data) data.force_encoding(Encoding::ASCII_8BIT) @data = data parse() end |
Instance Attribute Details
#packages ⇒ Object (readonly)
Returns the value of attribute packages.
449 450 451 |
# File 'lib/android/resource.rb', line 449 def packages @packages end |
Instance Method Details
#find(rsc_id, opt = {}) ⇒ Object
This method only support string resource for now.
Always return nil if assign not string type res id.
This method only support string resource for now. find resource by resource id
480 481 482 |
# File 'lib/android/resource.rb', line 480 def find(rsc_id, opt={}) first_pkg.find(rsc_id, opt) end |
#first_pkg ⇒ Object
499 500 501 |
# File 'lib/android/resource.rb', line 499 def first_pkg @packages.first[1] end |
#package_count ⇒ Fixnum
Returns number of packages.
464 465 466 |
# File 'lib/android/resource.rb', line 464 def package_count @res_table.package_count end |
#res_hex_id(readable_id) ⇒ String
convert readable resource id to hex id
495 496 497 |
# File 'lib/android/resource.rb', line 495 def res_hex_id(readable_id) first_pkg.res_hex_id(readable_id) end |
#res_readable_id(hex_id) ⇒ String
Returns readable resource id (‘@string/key’).
487 488 489 |
# File 'lib/android/resource.rb', line 487 def res_readable_id(hex_id) first_pkg.res_readable_id(hex_id) end |
#strings ⇒ Array<String>
Returns all strings defined in arsc.
459 460 461 |
# File 'lib/android/resource.rb', line 459 def strings @string_pool.strings end |