Class: CTAPI::Command

Inherits:
APDU
  • Object
show all
Defined in:
lib/ctapi.rb

Overview

A command sent to the cardterminal.

Instance Attribute Summary

Attributes inherited from APDU

#data

Class Method Summary collapse

Methods inherited from APDU

#[], #initialize, #inspect, #to_s

Constructor Details

This class inherits a constructor from CTAPI::APDU

Class Method Details

.from_array(command) ⇒ Object

A Command is generated from an array of bytes of the form [ 0x12, 0x23, 0xa4].



430
431
432
# File 'lib/ctapi.rb', line 430

def self.from_array(command)
  new(command.pack('C*'))
end

.from_string(command) ⇒ Object

A Command is generated from a string of the form ‘12:23:a4’ or ‘12 23 a4’.



423
424
425
426
# File 'lib/ctapi.rb', line 423

def self.from_string(command)
  command = command.split(/[ :]/).map { |x| Integer '0x' + x }
  from_array(command)
end