Class: EventflitClient::Channels

Inherits:
Object
  • Object
show all
Defined in:
lib/eventflit-client/channels.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger = EventflitClient.logger) ⇒ Channels

Returns a new instance of Channels.



6
7
8
9
# File 'lib/eventflit-client/channels.rb', line 6

def initialize(logger=EventflitClient.logger)
  @logger = logger
  @channels = {}
end

Instance Attribute Details

#channelsObject (readonly)

Returns the value of attribute channels.



4
5
6
# File 'lib/eventflit-client/channels.rb', line 4

def channels
  @channels
end

Instance Method Details

#add(channel_name, user_data = nil) ⇒ Object Also known as: <<



11
12
13
# File 'lib/eventflit-client/channels.rb', line 11

def add(channel_name, user_data=nil)
  @channels[channel_name] ||= Channel.new(channel_name, user_data, @logger)
end

#empty?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/eventflit-client/channels.rb', line 23

def empty?
  @channels.empty?
end

#find(channel_name) ⇒ Object Also known as: []



15
16
17
# File 'lib/eventflit-client/channels.rb', line 15

def find(channel_name)
  @channels[channel_name]
end

#remove(channel_name) ⇒ Object



19
20
21
# File 'lib/eventflit-client/channels.rb', line 19

def remove(channel_name)
  @channels.delete(channel_name)
end

#sizeObject



27
28
29
# File 'lib/eventflit-client/channels.rb', line 27

def size
  @channels.size
end