Class: Discorb::Snowflake

Inherits:
DiscordModel show all
Defined in:
lib/discorb/common.rb

Overview

Represents Snowflake of Discord.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#incrementInteger (readonly)

Increment of snowflake.

Returns:

  • (Integer)

    Increment of snowflake.



# File 'lib/discorb/common.rb', line 45

#process_idInteger (readonly)

Process ID of snowflake.

Returns:

  • (Integer)

    Process ID of snowflake.



# File 'lib/discorb/common.rb', line 45

#timestampTime (readonly)

Timestamp of snowflake.

Returns:

  • (Time)

    Timestamp of snowflake.



# File 'lib/discorb/common.rb', line 45

#worker_idInteger (readonly)

Worker ID of snowflake.

Returns:

  • (Integer)

    Worker ID of snowflake.



# File 'lib/discorb/common.rb', line 45

Instance Method Details

#==(other) ⇒ Boolean

Compares snowflake with other object.

Parameters:

  • other (#to_s)

    Object to compare with.

Returns:

  • (Boolean)

    True if snowflake is equal to other object.



89
90
91
92
93
# File 'lib/discorb/common.rb', line 89

def ==(other)
  return false unless other.respond_to?(:to_s)

  to_s == other.to_s
end

#eql?(other) ⇒ Boolean

Alias of #==.

Returns:

  • (Boolean)


98
99
100
# File 'lib/discorb/common.rb', line 98

def eql?(other)
  self == other
end

#hashObject

Return hash of snowflake.



103
104
105
# File 'lib/discorb/common.rb', line 103

def hash
  to_s.hash
end

#to_iInteger

Integerize snowflake.

Returns:

  • (Integer)

    Integerized snowflake.



78
79
80
# File 'lib/discorb/common.rb', line 78

def to_i
  @value.to_i
end

#to_sString

Stringify snowflake.

Returns:

  • (String)

    Stringified snowflake.



69
70
71
# File 'lib/discorb/common.rb', line 69

def to_s
  @value.to_s
end