Class: Mifare::Tag
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from NFC::Tag
#connect, #present?, #processed!, #processed?, #uid, #uid_hex
Constructor Details
#initialize(target, reader) ⇒ Tag
Returns a new instance of Tag.
37
38
39
40
41
42
43
|
# File 'lib/ruby-nfc/tags/mifare/tag.rb', line 37
def initialize(target, reader)
super(target, reader)
@pointer = Mifare.freefare_tag_new(reader.ptr, target)
raise Mifare::Error, "Unknown mifare tag" if @pointer.null?
end
|
Class Method Details
.match?(target) ⇒ Boolean
62
63
64
|
# File 'lib/ruby-nfc/tags/mifare/tag.rb', line 62
def self.match?(target)
SAKS.values.include?(target[:nti][:nai][:btSak])
end
|
Instance Method Details
#disconnect ⇒ Object
frees memory allocated for mifare tag
54
55
56
|
# File 'lib/ruby-nfc/tags/mifare/tag.rb', line 54
def disconnect
Mifare.freefare_free_tag(@pointer)
end
|
#name ⇒ Object
45
46
47
|
# File 'lib/ruby-nfc/tags/mifare/tag.rb', line 45
def name
Mifare.freefare_get_tag_friendly_name(@pointer)
end
|
#sak ⇒ Object
58
59
60
|
# File 'lib/ruby-nfc/tags/mifare/tag.rb', line 58
def sak
target.sak
end
|
#to_s ⇒ Object
49
50
51
|
# File 'lib/ruby-nfc/tags/mifare/tag.rb', line 49
def to_s
"#{uid_hex} #{name} SAK: 0x#{@target.sak.to_s(16)}"
end
|