module MijDiscord::Data::IDObject

Attributes

id[R]
to_id[R]

Public Class Methods

synthesize(time) click to toggle source
# File lib/mij-discord/data.rb, line 26
def self.synthesize(time)
  ms = (time.to_f * 1000).to_i
  (ms - DISCORD_EPOCH) << 22
end
timestamp(id) click to toggle source
# File lib/mij-discord/data.rb, line 31
def self.timestamp(id)
  ms = (id >> 22) + DISCORD_EPOCH
  Time.at(ms / 1000.0).utc
end

Public Instance Methods

==(other) click to toggle source
# File lib/mij-discord/data.rb, line 16
def ==(other)
  @id == (other.respond_to?(:to_id) ? other.to_id : other)
end
Also aliased as: eql?
creation_time() click to toggle source
# File lib/mij-discord/data.rb, line 22
def creation_time
  IDObject.timestamp(@id)
end
eql?(other)
Alias for: ==
hash() click to toggle source
# File lib/mij-discord/data.rb, line 12
def hash
  @id.hash
end