Class: FileTopic
- Inherits:
-
Object
- Object
- FileTopic
- Defined in:
- lib/file_topic.rb
Overview
FileTopic - a topic to post messages to that queues can listen to
Instance Attribute Summary collapse
-
#topic_location ⇒ Object
readonly
Returns the value of attribute topic_location.
Instance Method Summary collapse
-
#initialize(channel_location, topic_name) ⇒ FileTopic
constructor
A new instance of FileTopic.
- #publish(message) ⇒ Object
Constructor Details
#initialize(channel_location, topic_name) ⇒ FileTopic
Returns a new instance of FileTopic.
7 8 9 10 |
# File 'lib/file_topic.rb', line 7 def initialize(channel_location, topic_name) @topic_location = channel_location + '/' + topic_name FileUtils.mkdir_p @topic_location end |
Instance Attribute Details
#topic_location ⇒ Object (readonly)
Returns the value of attribute topic_location.
6 7 8 |
# File 'lib/file_topic.rb', line 6 def topic_location @topic_location end |
Instance Method Details
#publish(message) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/file_topic.rb', line 12 def publish() = FileMessage.new SecureRandom.hex(20).to_s + '.msg' Dir.glob(@topic_location + '/*').select do |queue_location| next unless File.directory? queue_location .(queue_location, ) end end |