Class: Pechkin::Chanel
- Inherits:
-
Object
- Object
- Pechkin::Chanel
- Defined in:
- lib/pechkin/channel.rb
Overview
Creates object which can send messages to assigned chanels
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize(connector, channel_list, logger = ::Logger.new(STDOUT)) ⇒ Chanel
constructor
A new instance of Chanel.
- #send_message(message, data, message_desc) ⇒ Object
Constructor Details
#initialize(connector, channel_list, logger = ::Logger.new(STDOUT)) ⇒ Chanel
Returns a new instance of Chanel.
6 7 8 9 10 11 |
# File 'lib/pechkin/channel.rb', line 6 def initialize(connector, channel_list, logger = ::Logger.new(STDOUT)) @connector = connector @channel_list = channel_list @channel_list = [channel_list] unless channel_list.is_a?(Array) @logger = logger end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
4 5 6 |
# File 'lib/pechkin/channel.rb', line 4 def logger @logger end |
Instance Method Details
#send_message(message, data, message_desc) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pechkin/channel.rb', line 13 def (, data, ) text = .nil? ? '' : Message.new(data).render() = substitute(data, ) logger.warn 'Resulting text is empty' if text.empty? results = @channel_list.map do |id| @connector.(id, text, ) end process_results(, results) end |