class APDU::Response
Public Class Methods
new(response)
click to toggle source
# File lib/ruby-nfc/apdu/response.rb, line 5 def initialize(response) resp_8bit = response.dup resp_8bit.force_encoding('ASCII-8BIT') raise APDU::Error, "Response must be at least 2-bytes long" if resp_8bit.size < 2 @response = resp_8bit end
Public Instance Methods
[](index)
click to toggle source
# File lib/ruby-nfc/apdu/response.rb, line 44 def [](index) @response[index] end
data()
click to toggle source
# File lib/ruby-nfc/apdu/response.rb, line 36 def data @response[0...-2] end
raise_errno!()
click to toggle source
Public: Raises APDU::Errno
if self.sw is not equal 0x9000
# File lib/ruby-nfc/apdu/response.rb, line 15 def raise_errno! raise APDU::Errno.new(sw) if sw != 0x9000 self end
sw()
click to toggle source
Public: Return Status Word of an APDU
response. Status Word is a two-byte result code
# File lib/ruby-nfc/apdu/response.rb, line 22 def sw @response[-2, 2].unpack('n').pop end
sw1()
click to toggle source
Public: Return high byte of Status Word
# File lib/ruby-nfc/apdu/response.rb, line 27 def sw1 @response[-2, 1].unpack('C').pop end
sw2()
click to toggle source
Public: Return low byte of Status Word
# File lib/ruby-nfc/apdu/response.rb, line 32 def sw2 @response[-1,1].unpack('C').pop end
to_s()
click to toggle source
# File lib/ruby-nfc/apdu/response.rb, line 40 def to_s @response.unpack('H*').pop.upcase end