Sha256: 767e32071a1ff00a585e14c5705e2c1b19ad4b808f001a0acb65255391fc8b91
Contents?: true
Size: 1.33 KB
Versions: 36
Compression:
Stored size: 1.33 KB
Contents
// Some Ruby-ish String extensions // from http://code.google.com/p/inflection-js/ if (!String.prototype.camelize) String.prototype.camelize = function(lowFirstLetter) { var str=this; //.toLowerCase(); var str_path=str.split('/'); for(var i=0;i<str_path.length;i++) { var str_arr=str_path[i].split('_'); var initX=((lowFirstLetter&&i+1==str_path.length)?(1):(0)); for(var x=initX;x<str_arr.length;x++) str_arr[x]=str_arr[x].charAt(0).toUpperCase()+str_arr[x].substring(1); str_path[i]=str_arr.join(''); } str=str_path.join('::'); return str; }; if (!String.prototype.capitalize) String.prototype.capitalize = function() { var str=this.toLowerCase(); str=str.substring(0,1).toUpperCase()+str.substring(1); return str; }; if (!String.prototype.humanize) String.prototype.humanize = function(lowFirstLetter) { var str=this.toLowerCase(); str=str.replace(new RegExp('_id','g'),''); str=str.replace(new RegExp('_','g'),' '); if(!lowFirstLetter)str=str.capitalize(); return str; }; // This one is borrowed from prototype.js if (!String.prototype.underscore) String.prototype.underscore = function() { return this.replace(/::/g, '/') .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2') .replace(/([a-z\d])([A-Z])/g, '$1_$2') .replace(/-/g, '_') .toLowerCase(); };
Version data entries
36 entries across 36 versions & 1 rubygems