Class: I2pStringData

Inherits:
BinData::BasePrimitive
  • Object
show all
Defined in:
lib/ip2proxy_ruby/i2p_string_data.rb

Instance Method Summary collapse

Instance Method Details

#read_and_return_value(io) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/ip2proxy_ruby/i2p_string_data.rb', line 3

def read_and_return_value(io)
  country_long = eval_parameter(:country_long)
  io.seekbytes(-4) if country_long
  file = io.instance_variable_get('@raw_io')
  addr = BinData::Uint32le.read(io)
  old_offset = file.tell
  country_long ? file.seek(addr + 3) : file.seek(addr)
  length = BinData::Uint8.read(file)
  res = BinData::String.new(:length => length).read(file)
  file.seek(old_offset)
  res
end