class Resilience::Attribute
Attributes
bytes[RW]
pos[RW]
Public Class Methods
new(args={})
click to toggle source
# File lib/resilience/attribute.rb, line 12 def initialize(args={}) @pos = args[:pos] @bytes = args[:bytes] end
read()
click to toggle source
# File lib/resilience/attribute.rb, line 21 def self.read pos = image.pos packed = image.read(4) return new if packed.nil? attr_len = packed.unpack('L').first return new if attr_len == 0 image.seek pos value = image.read(attr_len) new(:pos => pos, :bytes => value) end
Public Instance Methods
[](key)
click to toggle source
# File lib/resilience/attribute.rb, line 37 def [](key) return bytes[key] end
empty?()
click to toggle source
# File lib/resilience/attribute.rb, line 17 def empty? bytes.nil? || bytes.empty? end
to_s()
click to toggle source
# File lib/resilience/attribute.rb, line 41 def to_s bytes.collect { |a| a.to_s(16) }.join(' ') end
unpack(format)
click to toggle source
# File lib/resilience/attribute.rb, line 33 def unpack(format) bytes.unpack(format) end