class BluepanClient::ApplyVars

Public Class Methods

call(string, object) click to toggle source
# File lib/bluepan_client/services/apply_vars.rb, line 8
def self.call(string, object)
  self.new(string: string, object: object).()
end

Public Instance Methods

call() click to toggle source
# File lib/bluepan_client/services/apply_vars.rb, line 12
def call
  matches = string.scan(/:\w+/)
  matches.reduce(string) do |str, var|
    method_name = var.gsub(":", "")
    value = object.send(method_name)
    str.gsub(var, value.to_s)
  end
end