Class: Smartware::Interface::PinPad

Inherits:
Smartware::Interface show all
Defined in:
lib/smartware/interfaces/pin_pad.rb

Defined Under Namespace

Classes: PinPadError

Constant Summary collapse

DEVICE_NOT_READY =

Error codes

1
DEVICE_ERROR =
2
INPUT_PLAINTEXT =

Input modes

1
INPUT_PIN =
2
ASCII =

Pin block formats

0
ISO9564_0 =
1
ISO9564_1 =
2
ISO9564_3 =
3
IBM3624 =
4

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, service) ⇒ PinPad

Returns a new instance of PinPad.



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/smartware/interfaces/pin_pad.rb', line 40

def initialize(config, service)
  super

  device_not_ready

  @device.imk_source = method :imk_source
  @device.post_configuration = method :post_configuration
  @device.device_ready = method :device_ready
  @device.device_not_ready = method :device_not_ready
  @device.input_event = method :input_event

end

Class Method Details

.safe_proxy(*methods) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/smartware/interfaces/pin_pad.rb', line 21

def self.safe_proxy(*methods)
  methods.each do |method|
    class_eval <<-END
    def #{method}(*args)
      result = @device.#{method}(*args)
      update_status :error, nil
      result
    rescue PinPadError => e
      Logging.logger.error "Pin pad command failed: #\{e}"
      update_status :error, DEVICE_ERROR
      nil
    end
    END
  end
end