Class: Android::Resource::Chunk

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

Instance Method Summary collapse

Constructor Details

#initialize(data, offset) ⇒ Chunk

Returns a new instance of Chunk.



10
11
12
13
14
# File 'lib/android/resource.rb', line 10

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

Instance Method Details

#current_positionObject



30
31
32
# File 'lib/android/resource.rb', line 30

def current_position
  @data_io.pos
end

#exec_parseObject



15
16
17
18
19
20
# File 'lib/android/resource.rb', line 15

def exec_parse
  @data_io = StringIO.new(@data, 'rb')
  @data_io.seek(@offset)
  parse
  @data_io.close
end

#read_int16Object



24
25
26
# File 'lib/android/resource.rb', line 24

def read_int16
  @data_io.read(2).unpack('v')[0]
end

#read_int32Object



21
22
23
# File 'lib/android/resource.rb', line 21

def read_int32
  @data_io.read(4).unpack('V')[0]
end

#read_int8Object



27
28
29
# File 'lib/android/resource.rb', line 27

def read_int8
  @data_io.read(1).ord
end