module Thunderer::ChannelParser

Public Class Methods

interpolate_channel(channel, object) click to toggle source
# File lib/thunderer/channel_parser.rb, line 5
def interpolate_channel channel, object
  channel.gsub(/:\w*\b/, interpolation_hash(channel, object))
end

Private Class Methods

interpolation_hash(channel, object) click to toggle source
# File lib/thunderer/channel_parser.rb, line 11
def interpolation_hash channel, object
  {}.tap do |result|
    channel.scan(/:\w*\b/).map do |interpolation_key|
      object_method   = interpolation_key.gsub(':', '')
      replaced_string = object.send(object_method).to_s
      result[interpolation_key] =  replaced_string
    end
  end
end