Class: MemInspect::Viewer

Inherits:
Object
  • Object
show all
Defined in:
lib/mem_inspect/viewer.rb

Overview

An abstract viewer class

Use the PNGViewer as an example.

Direct Known Subclasses

AquatermViewer, PNGViewer

Instance Method Summary collapse

Constructor Details

#initialize(width, height) ⇒ Viewer

Intializes the visualization.



13
14
15
16
17
18
19
# File 'lib/mem_inspect/viewer.rb', line 13

def initialize(width, height)
  @width = width
  @height = height
  @max = @width * @height

  @mem_inspect = MemInspect.new
end

Instance Method Details

#coords_for(address) ⇒ Object

Returns x, y coordinates for address based on the width and height of the visualization.



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/mem_inspect/viewer.rb', line 25

def coords_for(address)
  index = address / 20

  if index > @max then
    raise "Ran out of plot space at index %d for 0x%x" % [index, address]
  end

  x = index % @width
  y = index / @width

  return x, y
end