Class: Android::Dex::DexObject

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

Overview

parsing dex object

Defined Under Namespace

Classes: ClassDataItem, ClassDefItem, CodeItem, DebugInfoItem, EncodedCatchHandler, EncodedCatchHandlerList, EncodedField, EncodedMethod, EncodedTypeAddrPair, FieldIdItem, Header, IdsList, MapItem, MapList, MethodIdItem, ProtoIdItem, StringDataItem, StringIdItem, TryItem, TypeIdItem, TypeList

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, offset) ⇒ DexObject

Returns a new instance of DexObject.



10
11
12
13
14
15
16
17
18
# File 'lib/android/dex/dex_object.rb', line 10

def initialize(data, offset)
  @data = data
  @offset = offset

  @params = {}
  @parsing_off = 0 # parsing offset
  parse()
  @size = @parsing_off
end

Instance Attribute Details

#sizeInteger (readonly)

Returns object size.

Returns:

  • (Integer)

    object size



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

def size
  @size
end

Instance Method Details

#[](sym) ⇒ Object

Returns dex header value which is related with sym.

Parameters:

  • sym (Symbol)

    should be included in #symbols

Returns:

  • (Object)

    dex header value which is related with sym



28
29
30
# File 'lib/android/dex/dex_object.rb', line 28

def [](sym)
  @params[sym.to_sym]
end

#inspectString

Returns:

  • (String)


33
34
35
36
37
38
39
# File 'lib/android/dex/dex_object.rb', line 33

def inspect
  str = "<#{self.class}\n"
  @params.each  do |key,val|
    str.concat "    #{key}: #{val}\n"
  end
  str.concat '>'
end

#symbolsArray<Symbol>

returns symbol keys

Returns:

  • (Array<Symbol>)

    header key



22
23
24
# File 'lib/android/dex/dex_object.rb', line 22

def symbols
  @params.keys
end