Class: PrintClient::TestTemplate
- Inherits:
-
Object
- Object
- PrintClient::TestTemplate
- Defined in:
- lib/print_client.rb
Instance Method Summary collapse
-
#initialize ⇒ TestTemplate
constructor
A new instance of TestTemplate.
- #start ⇒ Object
Constructor Details
#initialize ⇒ TestTemplate
Returns a new instance of TestTemplate.
129 130 131 132 133 |
# File 'lib/print_client.rb', line 129 def initialize config = YAML::load_file("./virtusprinter.yml") @vp_template = config['virtusprinter']['template'] @vp_port = config['virtusprinter']['port'] end |
Instance Method Details
#start ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/print_client.rb', line 135 def start template_name = @vp_template port = @vp_port puts "#{template_name} => #{port}" virtus_printer = VirtusPrinter.new result, data = virtus_printer.test_template(template_name, port) xml_doc = Nokogiri::XML(data) labels = xml_doc.css("labels label") labels.each do |l| port = l.at_css('port').content epl = l.at_css('epl').content epl.encode!('ISO-8859-1') puts port puts epl sp = SerialPort.new(port, 9600, 8, 1) sp.write epl end end |