class YubiOATH::CalculateAll

Public Class Methods

new(card) click to toggle source
# File lib/yubioath/calculate_all.rb, line 5
def initialize(card)
  @card = card
end

Public Instance Methods

call(timestamp:) click to toggle source
# File lib/yubioath/calculate_all.rb, line 9
def call(timestamp:)
  data = Request::Data.new(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[:codes].map do |code|
    [code.name, code.code.to_s]
  end.to_h
end