class NFC::Tag
Public Class Methods
match?(target)
click to toggle source
Matches any NFC
tag
# File lib/ruby-nfc/tags/tag.rb, line 58 def self.match?(target) true end
new(target, reader)
click to toggle source
# File lib/ruby-nfc/tags/tag.rb, line 3 def initialize(target, reader) @target = target @reader = reader @processed = false end
Public Instance Methods
connect(&block)
click to toggle source
# File lib/ruby-nfc/tags/tag.rb, line 9 def connect(&block) if block_given? begin self.instance_eval(&block) ensure disconnect end end end
disconnect()
click to toggle source
# File lib/ruby-nfc/tags/tag.rb, line 42 def disconnect; end
present?()
click to toggle source
# File lib/ruby-nfc/tags/tag.rb, line 27 def present? modulation = LibNFC::Modulation.new modulation[:nmt] = :NMT_ISO14443A modulation[:nbr] = :NBR_106 ptr = FFI::MemoryPointer.new(:char, @target[:nti][:nai][:szUidLen]) ptr.put_bytes(0, uid) res = LibNFC.nfc_initiator_select_passive_target(@reader.ptr, modulation, ptr, @target[:nti][:nai][:szUidLen], FFI::Pointer::NULL) return res >= 1 end
processed!()
click to toggle source
# File lib/ruby-nfc/tags/tag.rb, line 19 def processed! @target.processed! end
processed?()
click to toggle source
# File lib/ruby-nfc/tags/tag.rb, line 23 def processed? @target.processed? end
to_s()
click to toggle source
# File lib/ruby-nfc/tags/tag.rb, line 53 def to_s uid_hex end
uid()
click to toggle source
# File lib/ruby-nfc/tags/tag.rb, line 44 def uid uid_size = @target[:nti][:nai][:szUidLen] @target[:nti][:nai][:abtUid].to_s[0...uid_size] end
uid_hex()
click to toggle source
# File lib/ruby-nfc/tags/tag.rb, line 49 def uid_hex uid.unpack('H*').pop end