Module: IOStruct::InstanceMethods

Defined in:
lib/iostruct.rb

Overview

ClassMethods

Instance Method Summary collapse

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/iostruct.rb', line 110

def empty?
  to_a.all?{ |t| t == 0 || t.nil? || t.to_s.tr("\x00","").empty? }
end

#initialize(*args) ⇒ Object

allow initializing individual struct members by name, like:

PEdump::IMAGE_SECTION_HEADER.new(
  :VirtualSize    => 0x100,
  :VirtualAddress => 0x100000
)


119
120
121
122
123
124
125
126
127
128
# File 'lib/iostruct.rb', line 119

def initialize *args
  if args.size == 1 && args.first.is_a?(Hash)
    super()
    args.first.each do |k,v|
      send "#{k}=", v
    end
  else
    super
  end
end

#packObject



106
107
108
# File 'lib/iostruct.rb', line 106

def pack
  to_a.pack self.class.const_get('FORMAT')
end