Sha256: 467d00caf3f5ed0c1366d43dabf140bd86873066e1dd3a86e63003156f44c776

Contents?: true

Size: 1019 Bytes

Versions: 1

Compression:

Stored size: 1019 Bytes

Contents

require 'gtk3'

module Mireru
  module Command
    class Mireru
      USAGE = "Usage: mireru <file path>"

      class << self
        def run(*arguments)
          new.run(arguments)
        end
      end

      def initialize
      end

      def run(arguments)
        file = arguments[0]

        unless file
          puts("Error: no argument.")
          puts(USAGE)
          exit(false)
        end

        unless File.file?(file)
          puts("Error: missing file.")
          puts(USAGE)
          exit(false)
        end

        unless /\.(png|jpe?g|gif)$/i =~ file
          puts("Error: this file type is not support as yet.")
          puts(USAGE)
          exit(false)
        end

        image = Gtk::Image.new
        image.file = file
        
        window = Gtk::Window.new

        window.signal_connect("destroy") do
          Gtk.main_quit
        end

        window.border_width = 10
        window.add(image)
        window.show_all
        
        Gtk.main
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mireru-0.0.3 lib/mireru/command/mireru.rb