class D2L::Valence::TimestampError
TimestampError
¶ ↑
This class is aimed at parsing and providing diagnostics for time based issues between the D2L
Brightspace Server and Ruby Client
Public Class Methods
new(error_message)
click to toggle source
@param [String] D2L
Brightspace Server Error Message
# File lib/d2l/valence/timestamp_error.rb, line 8 def initialize(error_message) @error_message = error_message end
Public Instance Methods
server_skew()
click to toggle source
@return [Integer] difference in D2L
Server timestamp in seconds
# File lib/d2l/valence/timestamp_error.rb, line 13 def server_skew return 0 if server_time_in_seconds.nil? @server_skew ||= server_time_in_seconds - now_in_seconds end
timestamp_out_of_range?()
click to toggle source
@return [Integer] true if our timestamp is out of range with the D2L
Server
# File lib/d2l/valence/timestamp_error.rb, line 20 def timestamp_out_of_range? server_time_in_seconds != nil end
Private Instance Methods
now_in_seconds()
click to toggle source
@return [Integer] local timestamp now in seconds
# File lib/d2l/valence/timestamp_error.rb, line 32 def now_in_seconds Time.now.to_f.to_i end
parse_timestamp()
click to toggle source
# File lib/d2l/valence/timestamp_error.rb, line 36 def parse_timestamp match = Regexp.new(/Timestamp out of range\s*(\d+)/).match(@error_message) match[1].to_i if !match.nil? && match.length >= 2 end
server_time_in_seconds()
click to toggle source
@return [Integer] D2L
Server timestamp
# File lib/d2l/valence/timestamp_error.rb, line 27 def server_time_in_seconds @server_timestamp ||= parse_timestamp end