module Helpema::ZBar

Attributes

screenshot[RW]
version[RW]

Public Instance Methods

cam() click to toggle source
# File lib/helpema/zbar.rb, line 26
    def cam() = ZBar._cam()

    ZBar.define_command(:_img,
                        cmd: 'zbarimg',
                        version: ZBar.version,
                        usage: {q:true,raw:true,arg0:nil},
                        synonyms: {filename: :arg0})
    def img(filename) = ZBar._img(filename:filename)

    def screen
      raw = nil
      Dir.mktmpdir do |tmpdir|
       _ = File.join(tmpdir, "#{$$}.#{Time.now.to_f}.png")
       raw = _ if ZBar.snapshot(_) and not (_=ZBar.img(_).chomp).empty?
      end
      raw
    end

    extend self
  end
end
img(filename) click to toggle source
# File lib/helpema/zbar.rb, line 33
  def img(filename) = ZBar._img(filename:filename)

  def screen
    raw = nil
    Dir.mktmpdir do |tmpdir|
     _ = File.join(tmpdir, "#{$$}.#{Time.now.to_f}.png")
     raw = _ if ZBar.snapshot(_) and not (_=ZBar.img(_).chomp).empty?
    end
    raw
  end

  extend self
end
screen() click to toggle source
# File lib/helpema/zbar.rb, line 35
def screen
  raw = nil
  Dir.mktmpdir do |tmpdir|
   _ = File.join(tmpdir, "#{$$}.#{Time.now.to_f}.png")
   raw = _ if ZBar.snapshot(_) and not (_=ZBar.img(_).chomp).empty?
  end
  raw
end
snapshot(filename) click to toggle source
# File lib/helpema/zbar.rb, line 10
def snapshot(filename)
  system(*ZBar.screenshot, filename)
end