Sha256: bde72996b500f7a71b88f6461d1d6b22e519a8aad395d97498d89e29a19e5a3a

Contents?: true

Size: 569 Bytes

Versions: 2

Compression:

Stored size: 569 Bytes

Contents

module Twilio
  module Utils

    def twilify(something)
      if something.is_a? Hash
        Hash[*something.to_a.map {|a| [twilify(a[0]).to_sym, a[1]]}.flatten]
      else
        something.to_s.split('_').map do |s|
          [s[0,1].capitalize, s[1..-1]].join
        end.join
      end
    end

    def detwilify(something)
      if something.is_a? Hash
        Hash[*something.to_a.map {|pair| [detwilify(pair[0]).to_sym, pair[1]]}.flatten]
      else
        something.to_s.gsub(/[A-Z][a-z]*/) {|s| "_#{s.downcase}"}.gsub(/^_/, '')
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
twilio-ruby-0.0.4 lib/twilio-ruby/utils.rb
twilio-ruby-0.0.3 lib/twilio-ruby/utils.rb