Class: YubiOATH::Calculate
- Inherits:
-
Object
- Object
- YubiOATH::Calculate
- Defined in:
- lib/yubioath/calculate.rb
Defined Under Namespace
Instance Method Summary collapse
- #call(name:, timestamp:) ⇒ Object
-
#initialize(card) ⇒ Calculate
constructor
A new instance of Calculate.
Constructor Details
#initialize(card) ⇒ Calculate
Returns a new instance of Calculate.
5 6 7 |
# File 'lib/yubioath/calculate.rb', line 5 def initialize(card) @card = card end |
Instance Method Details
#call(name:, timestamp:) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/yubioath/calculate.rb', line 9 def call(name:, timestamp:) data = Request::Data.new(name: name, timestamp: .to_i / 30) request = Request.new(data: data.to_binary_s) bytes = @card.transmit(request.to_binary_s) response = Response.read(bytes) response.code.to_s end |