Method: Kernel#x
- Defined in:
- lib/source/ruby.rb
#x ⇒ Object
:nodoc:
1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 |
# File 'lib/source/ruby.rb', line 1490 def x #:nodoc: #function m$sprintf(){ # var i=0,arg,f=arguments[i++],ary=[],m,p,c,x; # while (f) { # if(m=f.match(/^[^%]+/)){ # ary.push(m[0]); # }else{ // ['mtch',[1]:'digit-final?',[2]:'plus?',[3]:'0 or \' plus non-$ ?',[4]:'minus?',[5]:'digit?',[6]:'. plus digit?',[7]:'flag'] # if(m = f.match(/^%%/)){ary.push('%');}else{ # if(m=f.match(/^%(?:(\\d+)\\$)?(\\+)?(0|'[^$])?(-)?(\\d+)?(?:\\.(\\d+))?([bcdEefGgiopsuXx])/)){ # if(((arg = arguments[m[1] || i++])==null)||(arg==undefined)){throw('ArgumentError: too few arguments.');}; # if(/[^sp]/.test(m[7])&&!(typeof(arg)=='number')){throw('TypeError: can\\'t convert '+''+' into Integer');}; # switch (m[7]) { # case'b':str=arg.toString(2);break; # case'c':str=String.fromCharCode(arg);break; # case'd':str=parseInt(arg);break; # case'E':str=(m[6]?arg.toExponential(m[6]):arg.toExponential()).toUpperCase();break; # case'e':str=m[6]?arg.toExponential(m[6]):arg.toExponential();break; # case'f':str=m[6] ? parseFloat(arg).toFixed(m[6]) : parseFloat(arg); break; // Needs work # case'G':str='';break; # case'g':str='';break; # case'i':str=parseInt(arg);break; # case'o':str=arg.toString(8);break; # case'p':str=$q(arg).m$inspect();break; # case's':str=((arg = String(arg)) && m[6] ? arg.substring(0, m[6]) : arg); break; // Does this work? # case'u':str=arg<0?'..'+(Math.pow(2,32)+arg):arg;break; # case'X':str=arg.toString(16).toUpperCase();break; # case'x':str=arg.toString(16);break; # }; # a = (/[def]/.test(m[7]) && m[2] && str > 0 ? '+' + str : str); # c = m[3] ? m[3] == '0' ? '0' : m[3].charAt(1) : ' '; # x = m[5] - String(a).length; # if(m[5]){for(var c2=c,x2=x,ary2=[];x2>0;ary2[--x2]=c2);p=ary2.join('');}else{p='';}; # ary.push(m[4]?str+p:p+str); # }else{throw('ArgumentError: malformed format string');}; # }; # }; # f = f.substring(m[0].length); # } # return ary.join(''); #} end |