Class: YubiOATH::Calculate

Inherits:
Object
  • Object
show all
Defined in:
lib/yubioath/calculate.rb

Defined Under Namespace

Classes: Request, Response

Instance Method Summary collapse

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: 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