Sha256: 2dd67f54e7631240c09d0539e6fb19e1c9ce7974bb17a05a2d75d6e3b9c10357

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 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
      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

2 entries across 2 versions & 2 rubygems

Version Path
cajun-smile-0.2.0 lib/smile/param_converter.rb
smile-0.2.0 lib/smile/param_converter.rb