Module: IOStruct::InstanceMethods
- Defined in:
- lib/iostruct.rb
Overview
ClassMethods
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(*args) ⇒ Object
allow initializing individual struct members by name, like: PEdump::IMAGE_SECTION_HEADER.new( :VirtualSize => 0x100, :VirtualAddress => 0x100000 ).
- #pack ⇒ Object
Instance Method Details
#empty? ⇒ Boolean
118 119 120 |
# File 'lib/iostruct.rb', line 118 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
)
127 128 129 130 131 132 133 134 135 136 |
# File 'lib/iostruct.rb', line 127 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 |
#pack ⇒ Object
114 115 116 |
# File 'lib/iostruct.rb', line 114 def pack to_a.pack self.class.const_get('FORMAT') end |