Sha256: c86c60dca369ce19e8a974ae084d4bfecb356e43aab1192129d58b7da5fdac44

Contents?: true

Size: 714 Bytes

Versions: 3

Compression:

Stored size: 714 Bytes

Contents

require "stringio"
require "hexdump"

module Mireru
  module Widget
    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
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mireru-0.2.1 lib/mireru/widget/binary.rb
mireru-0.2.0 lib/mireru/widget/binary.rb
mireru-0.1.9 lib/mireru/widget/binary.rb