lib/tamashii/agent/device/card_reader/pn532_uart.rb in tamashii-agent-0.3.1 vs lib/tamashii/agent/device/card_reader/pn532_uart.rb in tamashii-agent-0.3.3
- old
+ new
@@ -7,26 +7,16 @@
module CardReader
class Pn532Uart < Base
def initialize(*args)
super
@ctx = NFC::Context.new
- @dev = @ctx.open "pn532_uart:#{fetch_path}"
+ @dev = @ctx.open "pn532_uart:#{fetch_option(:path, default_path)}"
@card_type = @options[:card_type] || :felica
logger.info "Card type enabled: #{@card_type}"
end
def default_path
"/dev/ttyAMA0"
- end
-
- def fetch_path
- if @options.has_key?(:path)
- path = @options[:path]
- else
- path = default_path
- logger.warn "No path specified. Use default path: #{path}"
- end
- path
end
def poll_uid
tag = @dev.poll(@card_type)
if tag && !tag.is_a?(Integer)