Sha256: 9fd1c12aacb5923c2a1e4087a990e2911d682d20d2c8b9b94f18c34a3249919f
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
require_relative 'printer' module Sapos module Print class QReader class << self attr_accessor :printer_config, :verbose end attr_accessor :pubnub, :printer, :config def self.run! reader = QReader.new callback = Pubnub::SubscribeCallback.new( message: -> (envelope){ msg = envelope.result[:data][:message] print_control = nil document_number = nil if msg.is_a?(Hash) msg = msg['document'] print_control = msg['print_control'] document_number = msg['document_number'] end document = Base64.decode64(msg) if reader.printer.print(document: document, print_control: print_control, document_number: document_number) puts "OK" else puts "Printer Error".red end }, presence: ->(envelope){}, status: ->(envelope){} ) reader.pubnub.add_listener(callback: callback) reader.pubnub.subscribe(channels: reader.config.q) ARGV.clear while line = gets do #Wait forever ;-) end end def initialize @config = QReader.printer_config @printer = Printer.new(@config) @pubnub = Pubnub.new(subscribe_key: @config.key, user_id: @config.user_id) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sapos-print-1.0.7 | lib/sapos/print/q_reader.rb |