class Authmac::TimestampChecker

Public Class Methods

new(max_behind, max_ahead) click to toggle source
# File lib/authmac/timestamp_checker.rb, line 3
def initialize(max_behind, max_ahead)
  @max_behind = max_behind
  @max_ahead  = max_ahead
end

Public Instance Methods

validate(timestamp) click to toggle source
# File lib/authmac/timestamp_checker.rb, line 8
def validate(timestamp)
  not_too_old(timestamp) and not_too_new(timestamp)
end

Private Instance Methods

not_too_new(timestamp) click to toggle source
# File lib/authmac/timestamp_checker.rb, line 18
def not_too_new(timestamp)
  Time.at(timestamp) <= (Time.now + @max_ahead)
end
not_too_old(timestamp) click to toggle source
# File lib/authmac/timestamp_checker.rb, line 14
def not_too_old(timestamp)
  (Time.now - @max_behind) <= Time.at(timestamp)
end