Sha256: 8d82b91a5ac88a90be4c4cf55f70dc3bc38e8f31cebad752bc24bf908958ba8f

Contents?: true

Size: 1.39 KB

Versions: 4

Compression:

Stored size: 1.39 KB

Contents

module Smile::ParamConverter
  module_function
  
  def convert( param, value=nil )
    key = nil
    case param.to_s.downcase.to_sym
      when :popular_category
        key = :popularCategory
      when :geo_all 
        key = :geoAll
      when :geo_keyword 
        key = :geoKeyword
      when :geo_search 
        key = :geoSearch
      when :geo_community
        key = :geoCommunity 
      when :open_search_keyword
        key = :openSearchKeyword
      when :user_keyword 
        key = :userkeyword
      when :nickname_recent 
        key = :nicknameRecent
      when :nickname_popular 
        key = :nicknamePopular
      when :user_comments 
        key = :userComments
      when :geo_user 
        key = :geoUser
      when :geo_album 
        key = :geoAlbum
      when :size
        key = :Size
        value = value.titlecase
      when :image_count
        key = :ImageCount
      when :data
        key = :Data
      when :type
        key = :Type
      when :image_id
        key = :ImageID
      when :image_key
        key = :ImageKey
      when :image_count
        key = :ImageCount
      when :nickname, :nick_name
        key = :NickName
      else
        key = param
    end
    
    [ key, value ]
  end
  
  def clean_hash_keys( hash_to_clean )
    cleaned_hash ={}
    hash_to_clean.each_pair do |key,value|
      cleaned_hash[convert( key ).first] = value
    end
    cleaned_hash
  end
  
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
cajun-smile-0.2.1 lib/smile/param_converter.rb
cajun-smile-0.3.0 lib/smile/param_converter.rb
smile-0.3.0 lib/smile/param_converter.rb
smile-0.2.1 lib/smile/param_converter.rb