Module: MijDiscord::Data::IDObject
- Included in:
- Application, Channel, Emoji, InviteChannel, InviteServer, Message, Overwrite, Role, Server, User
- 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
27 28 29 30 |
# File 'lib/mij-discord/data.rb', line 27 def self.synthesize(time) ms = (time.to_f * 1000).to_i (ms - DISCORD_EPOCH) << 22 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 25 |
# File 'lib/mij-discord/data.rb', line 22 def creation_time ms = (@id >> 22) + DISCORD_EPOCH Time.at(ms / 1000.0).utc end |
#hash ⇒ Object
12 13 14 |
# File 'lib/mij-discord/data.rb', line 12 def hash @id.hash end |