Class: Evolis::PremiumSdk::Print
- Defined in:
- lib/evolis/premium_sdk/print.rb
Constant Summary
Constants inherited from SdkBase
Instance Attribute Summary
Attributes inherited from SdkBase
Instance Method Summary collapse
-
#begin(device) ⇒ String
Initiates a printing session.
-
#end ⇒ true
Ends the session.
-
#initialize(host, port) ⇒ Print
constructor
Initializes the class and sets SDK host and port.
-
#print ⇒ true
Launches a printing job.
-
#set(data) ⇒ true
Sets the printing parameters.
-
#set_bitmap(data, face = 'front', panel = 'color') ⇒ true
Defines the graphic data to be printed.
Methods inherited from SdkBase
#active_session?, #call_rpc, #list_settings, #print_setting, #request, #response, #sanitize_parameters, #valid_base64?, #valid_settings?
Constructor Details
#initialize(host, port) ⇒ Print
Initializes the class and sets SDK host and port
11 12 13 |
# File 'lib/evolis/premium_sdk/print.rb', line 11 def initialize(host, port) super(host, port, 'PRINT') end |
Instance Method Details
#begin(device) ⇒ String
Initiates a printing session
19 20 21 22 23 |
# File 'lib/evolis/premium_sdk/print.rb', line 19 def begin(device) self.active_session = call_rpc('Begin', { device: device }) end |
#end ⇒ true
Ends the session
86 87 88 89 90 91 92 |
# File 'lib/evolis/premium_sdk/print.rb', line 86 def end raise Error::NoActiveSessionError.new unless active_session? call_rpc('End', { session: self.active_session }) end |
#print ⇒ true
When calling the ‘print`, the `get_event` method from the `Supervision` service must be polled on a regular basis. If an event is identified, an action must be taken so that the print job can be finalized.
Launches a printing job
74 75 76 77 78 79 80 |
# File 'lib/evolis/premium_sdk/print.rb', line 74 def print raise Error::NoActiveSessionError.new unless active_session? call_rpc('Print', { session: self.active_session }) end |
#set(data) ⇒ true
Sets the printing parameters
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/evolis/premium_sdk/print.rb', line 32 def set(data) raise Error::NoActiveSessionError.new unless active_session? raise Error::InvalidPrintSettingError.new data unless valid_settings?(data) data = data.join(';') if data.is_a?(Array) call_rpc('Set', { session: self.active_session, data: data }) end |
#set_bitmap(data, face = 'front', panel = 'color') ⇒ true
Can only be run once per card side and panel type
Defines the graphic data to be printed
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/evolis/premium_sdk/print.rb', line 54 def set_bitmap(data, face = 'front', panel = 'color') raise Error::NoActiveSessionError.new unless active_session? raise Error::NoSuchFaceError.new face unless %w[front back].include?(face.downcase) raise Error::NoSuchPanelError.new panel unless %w[color resin varnish].include?(panel.downcase) raise Error::Base64FormatError.new data unless valid_base64?(data) call_rpc('SetBitmap', { session: self.active_session, face: face, panel: panel, data: data }) end |