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

#increment -> Integer (readonly)

Increment of snowflake.

Returns:

  • (Integer)

    Increment of snowflake.



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

#process_id -> Integer (readonly)

Process ID of snowflake.

Returns:

  • (Integer)

    Process ID of snowflake.



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

#timestamp -> Time (readonly)

Timestamp of snowflake.

Returns:

  • (Time)

    Timestamp of snowflake.



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

#worker_id -> Integer (readonly)

Worker ID of snowflake.

Returns:

  • (Integer)

    Worker ID of snowflake.



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

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.



94
95
96
97
98
# File 'lib/discorb/common.rb', line 94

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

  to_s == other.to_s
end

#eql?(other) -> Boolean

Alias of #==.

Returns:

  • (Boolean)


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

def eql?(other)
  self == other
end

#hash -> Object

Return hash of snowflake.



108
109
110
# File 'lib/discorb/common.rb', line 108

def hash
  to_s.hash
end

#to_i -> Integer

Integerize snowflake.

Returns:

  • (Integer)

    Integerized snowflake.



83
84
85
# File 'lib/discorb/common.rb', line 83

def to_i
  @value.to_i
end

#to_s -> String Also known as: to_str

Stringify snowflake.

Returns:

  • (String)

    Stringified snowflake.



72
73
74
# File 'lib/discorb/common.rb', line 72

def to_s
  @value.to_s
end