hasclass / core-lib

A port of the Ruby 1.9.3 corelib to coffeescript/javascript/node that conforms to rubyspec.org.
Other
545 stars 24 forks source link

Example from the main page isn't working because of missing size #18

Closed TobiaszCudnik closed 11 years ago

TobiaszCudnik commented 11 years ago

Example from the main page isn't working because of missing size method, all in 'god mode'. Code:

R.god_mode('')
"kampai".ljust(10, ' ') // => '  kampai  '
  .size() // 10
  .times(function(i) { console.log(i)} )

After some shallow debugging I suspect RWrapper to mess around with it.

BTW what's the point of these lines:

_str = R._str = (str) ->
  new RWrapper(str, _str)

It seems they will be executed each time I create a string and because of the outer scope it'll be nested one level deeper every time. Am i missing something?

hasclass commented 11 years ago

It's an experimental feature that works the same as the underscore _.chain().

_s.upcase("foo");  // FOO
_s("foo").upcase() // RWrapper {value: "FOO"}
  .downcase().      // RWrapper {value: "foo"}
  .valueOf()          // foo
hasclass commented 11 years ago

the size methods have been added b21b9478b9d8b4b43c07d55eefbbab466fd76878.