Class: BinData::Pointer
- Inherits:
-
BasePrimitive
- Object
- BasePrimitive
- BinData::Pointer
- Includes:
- ClassParametersPlugin
- Defined in:
- lib/binproxy/bd_util.rb
Instance Attribute Summary collapse
-
#ptr ⇒ Object
readonly
Returns the value of attribute ptr.
-
#val ⇒ Object
readonly
Returns the value of attribute val.
Instance Method Summary collapse
- #read_and_return_value(io) ⇒ Object
- #sensible_default ⇒ Object
-
#value_to_binary_string(v) ⇒ Object
XXX hacky below, handles reading only.
Methods included from ClassParametersPlugin
Methods inherited from BasePrimitive
Instance Attribute Details
#ptr ⇒ Object (readonly)
Returns the value of attribute ptr.
231 232 233 |
# File 'lib/binproxy/bd_util.rb', line 231 def ptr @ptr end |
#val ⇒ Object (readonly)
Returns the value of attribute val.
231 232 233 |
# File 'lib/binproxy/bd_util.rb', line 231 def val @val end |
Instance Method Details
#read_and_return_value(io) ⇒ Object
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/binproxy/bd_util.rb', line 233 def read_and_return_value(io) ptr_obj = get_parameter(:ptr_type).instantiate(nil,self) val_obj = get_parameter(:val_type).instantiate(nil,self) ptr = ptr_obj.read(io) rio = io.raw_io pos = rio.pos base = case get_parameter(:seek_from) when :raw_start then 0 when :start then io.initial_pos when :current then pos + ptr else raise "Invalid seek_from parameter" end rio.seek base + get_parameter(:seek_offset) + ptr val_obj.read(rio) rio.seek pos #{p: ptr_obj, v: val_obj} val_obj end |
#sensible_default ⇒ Object
262 263 264 265 |
# File 'lib/binproxy/bd_util.rb', line 262 def sensible_default #{p: 0, v: nil} get_parameter(:val_type).instantiate(nil,self) end |
#value_to_binary_string(v) ⇒ Object
XXX hacky below, handles reading only
258 259 260 |
# File 'lib/binproxy/bd_util.rb', line 258 def value_to_binary_string(v) v.to_binary_s end |