Class: NFC::Felica

Inherits:
Object
  • Object
show all
Defined in:
lib/nfc/felica.rb,
ext/nfc/nfc_felica.c

Instance Method Summary collapse

Instance Method Details

#abtIdObject



29
30
31
32
33
34
35
# File 'ext/nfc/nfc_felica.c', line 29

static VALUE abtId(VALUE self)
{
  nfc_felica_info * tag;
  Data_Get_Struct(self, nfc_felica_info, tag);

  return rb_str_new(tag->abtId, 8 );
}

#btResCodeObject



21
22
23
24
25
26
27
# File 'ext/nfc/nfc_felica.c', line 21

static VALUE btResCode(VALUE self)
{
  nfc_felica_info * tag;
  Data_Get_Struct(self, nfc_felica_info, tag);

  return INT2NUM(tag->btResCode);
}

#inspectObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/nfc/felica.rb', line 20

def inspect
# 78     printf("The following (NFC) Felica tag was found:\n\n");
# 79     printf("%18s","ID (NFCID2): "); print_hex(ti.tif.abtId,8);
# 80     printf("%18s","Parameter (PAD): "); print_hex(ti.tif.abtPad,8);
  pad = sprintf( (['%02x'] * 8 ).join('  '), *self.pad) 
  string_ary = [
    "(NFC) Felica Tag",
    "ID    (NFCID2): #{to_s '  '}",
    "Parameter(PAD): #{pad}"
  ]
  string_ary.join "\n"
end

#padObject



8
9
10
# File 'lib/nfc/felica.rb', line 8

def pad
  abtPad.unpack 'C*'
end

#sys_codeObject



12
13
14
# File 'lib/nfc/felica.rb', line 12

def sys_code
  abtSysCode.unpack 'C*'
end

#szLenObject

size_t szLen; byte_t btResCode; byte_t abtId; byte_t abtPad; byte_t abtSysCode;



13
14
15
16
17
18
19
# File 'ext/nfc/nfc_felica.c', line 13

static VALUE szLen(VALUE self)
{
  nfc_felica_info * tag;
  Data_Get_Struct(self, nfc_felica_info, tag);

  return INT2NUM(tag->szLen);
}

#to_s(join_string = '') ⇒ Object



16
17
18
# File 'lib/nfc/felica.rb', line 16

def to_s join_string = ''
  sprintf((['%02x'] * 8 ).join(join_string), * uid).upcase
end

#uidObject



4
5
6
# File 'lib/nfc/felica.rb', line 4

def uid
  abtId.unpack 'C*'
end