Class: Discorb::Snowflake

Inherits:
String
  • Object
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 49

#process_id -> Integer (readonly)

Process ID of snowflake.

Returns:

  • (Integer)

    Process ID of snowflake.



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

#timestamp -> Time (readonly)

Timestamp of snowflake.

Returns:

  • (Time)

    Timestamp of snowflake.



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

#worker_id -> Integer (readonly)

Worker ID of snowflake.

Returns:

  • (Integer)

    Worker ID of snowflake.



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

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.



79
80
81
82
83
# File 'lib/discorb/common.rb', line 79

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

  to_s == other.to_s
end

#eql?(other) -> Boolean

Alias of #==.

Returns:

  • (Boolean)


88
89
90
# File 'lib/discorb/common.rb', line 88

def eql?(other)
  self == other
end

#hash -> Object

Return hash of snowflake.



93
94
95
# File 'lib/discorb/common.rb', line 93

def hash
  to_s.hash
end

#inspect -> Object



113
114
115
# File 'lib/discorb/common.rb', line 113

def inspect
  "#<#{self.class} #{to_s}>"
end