Module: Mqttopia::Helpers::DataExtractor
- Included in:
- Subscriptions::Services::Base
- Defined in:
- lib/mqttopia/helpers/data_extractor.rb
Instance Method Summary collapse
Instance Method Details
#extract_trip_id(topic_name) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/mqttopia/helpers/data_extractor.rb', line 6 def extract_trip_id(topic_name) return unless topic_name.include?("trips/") match_data = topic_name.match(%r{trips/([^/]*)}) match_data && !match_data[1].empty? ? match_data[1] : nil end |
#extract_user_id(topic_name) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/mqttopia/helpers/data_extractor.rb', line 14 def extract_user_id(topic_name) return unless topic_name.include?("user/") match_data = topic_name.match(%r{user/([^/]*)}) match_data && !match_data[1].empty? ? match_data[1] : nil end |