Method: CTypes::Struct#to_h
- Defined in:
- lib/ctypes/struct.rb
#to_h(shallow: false) ⇒ Hash Also known as: to_hash
return a Hash representation of the data type
465 466 467 468 469 470 471 472 473 474 475 |
# File 'lib/ctypes/struct.rb', line 465 def to_h(shallow: false) out = {} self.class.fields.each do |field| value = send(field) unless shallow || value.is_a?(::Array) || !value.respond_to?(:to_h) value = value.to_h end out[field] = value end out end |