Sha256: 9ff7be5e223e6936d7cce2093a2176c1b97a6052f50afa92a24bc6e1dcd006ba
Contents?: true
Size: 1.05 KB
Versions: 2
Compression:
Stored size: 1.05 KB
Contents
module ResponseConverter TAG_CONVERTER = lambda do |tag| tag.snakecase.gsub(/@/, '').gsub(/unified_/, '').gsub(/current_/, '').to_sym end def convert_value(input) if input == 'True' || input == 'true' || input == 'TRUE' return true elsif input == 'False' || input == 'false' || input == 'FALSE' return false else begin return Integer(input) rescue StandardError => e begin return Float(input) rescue StandardError => e end end end input end def convert_response(input) if input.is_a?(Hash) input.each do |key, value| if value.is_a?(Hash) || value.is_a?(Array) convert_response(value) else input[key] = convert_value(value) end end elsif input.is_a?(Array) input.each_with_index do |value, index| if value.is_a?(Hash) || value.is_a?(Array) convert_response(value) else input[index] = convert_value(value) end end else input end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby-ecomm-client-1.1.0 | lib/ruby-ecomm-client/converter.rb |
ruby-ecomm-client-1.0.0 | lib/ruby-ecomm-client/converter.rb |