Skip to content

Instantly share code, notes, and snippets.

@st63jun
Created September 8, 2012 11:43
Show Gist options
  • Save st63jun/3674079 to your computer and use it in GitHub Desktop.
Save st63jun/3674079 to your computer and use it in GitHub Desktop.
libpafe-rubyで学生証をアレする
require 'pasori'
require 'nkf'
class StudentIdCard
def StudentIdCard.scan
ret = Hash.new
Pasori.open { |pasori|
pasori.felica_polling { |felica|
buf = ""
felica.foreach(felica.service[20]) { |data| buf << data }
ret[:felica_idm] = felica.idm.unpack("C*").map{|c| sprintf("%02X", c)}.join
ret[:id] = buf[0,7]
ret[:name] = NKF::nkf "-w8", buf[26,30].strip
}
}
ret
end
end
p StudentIdCard.scan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment