Sha256: 5ccc6737f5104e52de79b9608c78d8ddae222846e551a6f77855b6eb0c19cc46

Contents?: true

Size: 646 Bytes

Versions: 2

Compression:

Stored size: 646 Bytes

Contents

require "stringio"
require "hexdump"

module Mireru
  class Binary
    class << self
      def create(file)
        dump = hexdump(file).string
        create_text_view(dump)
      end

      private
      def hexdump(file)
        io = StringIO.new
        bytes = File.open(file, "rb").read(20 * 1024)
        Hexdump.dump(bytes, :output => io)
        io
      end

      def create_text_view(text)
        buffer = Gtk::TextBuffer.new
        buffer.text = text
        view = Gtk::TextView.new(buffer)
        view.editable = false
        view.override_font(Pango::FontDescription.new("Monospace"))
        view
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mireru-0.1.8 lib/mireru/binary.rb
mireru-0.1.7 lib/mireru/binary.rb