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.



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

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



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

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



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

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

#inspectString

Returns:

  • (String)


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

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

#symbolsArray<Symbol>

returns symbol keys

Returns:

  • (Array<Symbol>)

    header key



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

def symbols
  @params.keys
end