Module: MijDiscord::Data::IDObject
- Included in:
- Application, Channel, Emoji, InviteChannel, InviteServer, Message, Overwrite, Role, Server, User, Webhook
- Defined in:
- lib/mij-discord/data.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
(also: #to_id)
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #creation_time ⇒ Object
- #hash ⇒ Object
Instance Attribute Details
#id ⇒ Object (readonly) Also known as: to_id
Returns the value of attribute id.
9 10 11 |
# File 'lib/mij-discord/data.rb', line 9 def id @id end |
Class Method Details
.synthesize(time) ⇒ Object
26 27 28 29 |
# 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) ⇒ Object
31 32 33 34 |
# File 'lib/mij-discord/data.rb', line 31 def self.(id) ms = (id >> 22) + DISCORD_EPOCH Time.at(ms / 1000.0).utc end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
16 17 18 |
# File 'lib/mij-discord/data.rb', line 16 def ==(other) @id == (other.respond_to?(:to_id) ? other.to_id : other) end |
#creation_time ⇒ Object
22 23 24 |
# File 'lib/mij-discord/data.rb', line 22 def creation_time IDObject.(@id) end |
#hash ⇒ Object
12 13 14 |
# File 'lib/mij-discord/data.rb', line 12 def hash @id.hash end |