Module: IOStruct::InstanceMethods
- Defined in:
- lib/iostruct.rb
Overview
ClassMethods
Instance Attribute Summary collapse
-
#__offset ⇒ Object
Returns the value of attribute __offset.
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 Attribute Details
#__offset ⇒ Object
Returns the value of attribute __offset.
88 89 90 |
# File 'lib/iostruct.rb', line 88 def __offset @__offset end |
Instance Method Details
#empty? ⇒ Boolean
94 95 96 |
# File 'lib/iostruct.rb', line 94 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
)
103 104 105 106 107 108 109 110 111 112 |
# File 'lib/iostruct.rb', line 103 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
90 91 92 |
# File 'lib/iostruct.rb', line 90 def pack to_a.pack self.class.const_get('FORMAT') end |