Sha256: fd9f66e3848feae7eec2be90847fbcd18b0fc774dc97439474e97627ac8406fe

Contents?: true

Size: 420 Bytes

Versions: 3

Compression:

Stored size: 420 Bytes

Contents

module ErbAsterisk
  module Utils
    # Escape special symbols in extension name
    #
    # vnov -> v[n]ov
    # LongExtension1234! -> Lo[n]gE[x]te[n]sio[n]1234[!]
    #
    def escape_exten(exten)
      result = exten.each_char.reduce('') do |s, c|
        s << (%w(x z n . !).include?(c.downcase) ? "[#{c}]" : c)
      end

      log_debug("escape_exten: '#{exten}' => '#{result}'", 2)
      result
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
erb_asterisk-0.0.19 lib/erb_asterisk/utils.rb
erb_asterisk-0.0.18 lib/erb_asterisk/utils.rb
erb_asterisk-0.0.17 lib/erb_asterisk/utils.rb