Class: HexProgram

Inherits:
Object
  • Object
show all
Defined in:
lib/littlewire/gadgets/micronucleus.rb

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ HexProgram

Returns a new instance of HexProgram.



124
125
126
127
128
# File 'lib/littlewire/gadgets/micronucleus.rb', line 124

def initialize input
  @bytes = Hash.new(0xFF)
  input = input.read if input.is_a? IO
  parse input
end

Instance Method Details

#binaryObject



130
131
132
# File 'lib/littlewire/gadgets/micronucleus.rb', line 130

def binary
  bytes.pack('C*')
end

#bytesObject



134
135
136
137
138
139
140
# File 'lib/littlewire/gadgets/micronucleus.rb', line 134

def bytes
  highest_address = @bytes.keys.max
  
  bytes = Array.new(highest_address + 1) { |index|
    @bytes[index]
  }
end