Class: RubyCord::Snowflake

Inherits:
String
  • Object
show all
Defined in:
lib/rubycord/common.rb

Overview

Represents Snowflake of Discord.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#incrementInteger (readonly)

Returns Increment of snowflake.

Returns:

  • (Integer)

    Increment of snowflake.



# File 'lib/rubycord/common.rb', line 58

#process_idInteger (readonly)

Returns Process ID of snowflake.

Returns:

  • (Integer)

    Process ID of snowflake.



# File 'lib/rubycord/common.rb', line 58

#timestampTime (readonly)

Timestamp of snowflake.

Returns:

  • (Time)

    Timestamp of snowflake.



# File 'lib/rubycord/common.rb', line 58

#worker_idInteger (readonly)

Returns Worker ID of snowflake.

Returns:

  • (Integer)

    Worker ID of snowflake.



# File 'lib/rubycord/common.rb', line 58

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.



88
89
90
91
92
# File 'lib/rubycord/common.rb', line 88

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

  to_s == other.to_s
end

#eql?(other) ⇒ Boolean

Alias of #==.

Returns:

  • (Boolean)


97
98
99
# File 'lib/rubycord/common.rb', line 97

def eql?(other)
  self == other
end

#hashObject

Return hash of snowflake.



102
103
104
# File 'lib/rubycord/common.rb', line 102

def hash
  to_s.hash
end

#inspectString

Returns The object class and attributes.

Returns:

  • (String)

    The object class and attributes.



126
127
128
# File 'lib/rubycord/common.rb', line 126

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