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.



12
13
14
15
16
17
# File 'lib/android/resource.rb', line 12

def initialize(data, offset)
  data.force_encoding(Encoding::ASCII_8BIT)
  @data = data
  @offset = offset
  exec_parse
end

Instance Method Details

#current_positionObject



33
34
35
# File 'lib/android/resource.rb', line 33

def current_position
  @data_io.pos
end

#exec_parseObject



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

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

#read_int16Object



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

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

#read_int32Object



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

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

#read_int8Object



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

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