Class: Discorb::Shard

Inherits:
Object
  • Object
show all
Defined in:
lib/discorb/shard.rb

Overview

Represents a shard.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idInteger (readonly)

Returns The ID of the shard.

Returns:

  • (Integer)

    The ID of the shard.



9
10
11
# File 'lib/discorb/shard.rb', line 9

def id
  @id
end

#loggerLogger (readonly)

Returns The logger of the shard.

Returns:

  • (Logger)

    The logger of the shard.



13
14
15
# File 'lib/discorb/shard.rb', line 13

def logger
  @logger
end

#threadThread (readonly)

Returns The thread of the shard.

Returns:

  • (Thread)

    The thread of the shard.



11
12
13
# File 'lib/discorb/shard.rb', line 11

def thread
  @thread
end

Instance Method Details

#closevoid

This method returns an undefined value.

Stops the shard.



66
67
68
69
70
# File 'lib/discorb/shard.rb', line 66

def close
  @status = :closed
  @main_task&.stop
  @thread.kill
end

#inspectObject



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

def inspect
  "#<#{self.class} #{id}/#{@shard_count} #{@status}>"
end

#startvoid

This method returns an undefined value.

Starts the shard.



57
58
59
# File 'lib/discorb/shard.rb', line 57

def start
  @thread.wakeup
end