Class: BinData::Stringz

Inherits:
Single show all
Defined in:
lib/bindata/stringz.rb

Overview

A BinData::Stringz object is a container for a zero (“0”) terminated string.

For convenience, the zero terminator is not necessary when setting the value. Likewise, the returned value will not be zero terminated.

Parameters

Stringz objects accept all the params that BinData::Single does, as well as the following:

:max_length

The maximum length of the string including the zero byte.

Instance Method Summary collapse

Methods inherited from Single

#_do_read, #_num_bytes, #_write, #clear, #clear?, #done_read, #field_names, inherited, #initialize, #snapshot, #value=

Methods inherited from Base

#do_read, #initialize, #klass_lookup, lookup, mandatory_parameters, #num_bytes, optional_parameters, parameters, read, #read, register, #single_value?, #write

Constructor Details

This class inherits a constructor from BinData::Single

Instance Method Details

#valueObject

Overrides value to return the value of this data excluding the trailing zero byte.



23
24
25
26
# File 'lib/bindata/stringz.rb', line 23

def value
  v = super
  val_to_str(v).chomp("\0")
end