diff --git a/ChangeLog b/ChangeLog index bf2184cc81..68bd4468a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Fri Jul 6 05:38:44 2012 Eric Hodel + + * string.c (rb_str_bytesize): Improve documentation. Patch by Oscar + Del Ben from github issue #138. + * string.c (rb_str_empty): ditto. + * string.c (rb_str_times): ditto. + * string.c (rb_str_dump): ditto. + * string.c (rb_str_center): ditto. + Fri Jul 6 04:05:59 2012 Eric Hodel * ext/zlib/zlib.c (zstream_expand_buffer_without_gvl): Use diff --git a/string.c b/string.c index e275e577ea..c49a1b11dc 100644 --- a/string.c +++ b/string.c @@ -1147,7 +1147,10 @@ rb_str_length(VALUE str) * call-seq: * str.bytesize -> integer * - * Returns the length of str in bytes. + * Returns the length of +str+ in bytes. + * + * "\x80\u3042".bytesize #=> 4 + * "hello".bytesize #=> 5 */ static VALUE @@ -1163,6 +1166,7 @@ rb_str_bytesize(VALUE str) * Returns true if str has a length of zero. * * "hello".empty? #=> false + * " ".empty? #=> false * "".empty? #=> true */ @@ -1209,10 +1213,11 @@ rb_str_plus(VALUE str1, VALUE str2) * call-seq: * str * integer -> new_str * - * Copy---Returns a new String containing integer copies of - * the receiver. + * Copy --- Returns a new String containing +integer+ copies of the receiver. + * +integer+ must be greater than or equal to 0. * * "Ho! " * 3 #=> "Ho! Ho! Ho! " + * "Ho! " * 0 #=> "" */ VALUE @@ -4532,8 +4537,10 @@ rb_str_inspect(VALUE str) * call-seq: * str.dump -> new_str * - * Produces a version of str with all nonprinting characters replaced by + * Produces a version of +str+ with all non-printing characters replaced by * \nnn notation and all special characters escaped. + * + * "hello \n ''".dump #=> "\"hello \\n ''\" */ VALUE @@ -7126,11 +7133,11 @@ rb_str_rjust(int argc, VALUE *argv, VALUE str) /* * call-seq: - * str.center(integer, padstr) -> new_str + * str.center(width, padstr=' ') -> new_str * - * If integer is greater than the length of str, returns a new - * String of length integer with str centered and - * padded with padstr; otherwise, returns str. + * Centers +str+ in +width+. If +width+ is greater than the length of +str+, + * returns a new String of length +width+ with +str+ centered and padded with + * +padstr+; otherwise, returns +str+. * * "hello".center(4) #=> "hello" * "hello".center(20) #=> " hello "