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

#id -> Integer (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

#logger -> Logger (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

#thread -> Thread (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

#close! -> void

This method returns an undefined value.

Stops the shard.



64
65
66
67
68
# File 'lib/discorb/shard.rb', line 64

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

#inspect -> Object



70
71
72
# File 'lib/discorb/shard.rb', line 70

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

#start -> void

This method returns an undefined value.

Starts the shard.



55
56
57
# File 'lib/discorb/shard.rb', line 55

def start
  @thread.wakeup
end