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.
85 86 87 |
# File 'lib/iostruct.rb', line 85 def __offset @__offset end |
Instance Method Details
#empty? ⇒ Boolean
91 92 93 |
# File 'lib/iostruct.rb', line 91 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
)
100 101 102 103 104 105 106 107 108 109 |
# File 'lib/iostruct.rb', line 100 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
87 88 89 |
# File 'lib/iostruct.rb', line 87 def pack to_a.pack self.class.const_get('FORMAT') end |