From 18f4f0888513be990c164ecd5b3ea92e24570240 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 5 Mar 2011 20:25:08 +0000 Subject: * class.c: fix camelCase to snake_case in documentation code examples. patched by Andrew Grimm. fixes Bug #4469 * marshal.c: ditto. * proc.c: ditto. * sample/biorhythm.rb: ditto. * vm_eval.c: ditto. * vm_method.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 16 ++++++++++++++++ class.c | 10 +++++----- marshal.c | 4 ++-- proc.c | 14 +++++++------- sample/biorhythm.rb | 12 ++++++------ vm_eval.c | 8 ++++---- vm_method.c | 6 +++--- 7 files changed, 43 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index e3680c3ad0..188122176b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +Sun Mar 6 05:21:41 2011 NARUSE, Yui + + * class.c: fix camelCase to snake_case in documentation code examples. + patched by Andrew Grimm. fixes Bug #4469 + + * marshal.c: ditto. + + * proc.c: ditto. + + * sample/biorhythm.rb: ditto. + + * vm_eval.c: ditto. + + * vm_method.c: ditto. + + Sun Mar 6 03:22:27 2011 KOSAKI Motohiro * io.c (io_cntl): use rb_thread_io_blocking_region() instead diff --git a/class.c b/class.c index 0d7623350f..39e5e1447f 100644 --- a/class.c +++ b/class.c @@ -988,14 +988,14 @@ rb_class_public_instance_methods(int argc, VALUE *argv, VALUE mod) * obj's ancestors. * * class Klass - * def kMethod() + * def klass_method() * end * end * k = Klass.new - * k.methods[0..9] #=> [:kMethod, :freeze, :nil?, :is_a?, - * # :class, :instance_variable_set, - * # :methods, :extend, :__send__, :instance_eval] - * k.methods.length #=> 42 + * k.methods[0..9] #=> [:klass_method, :nil?, :===, + * # :==~, :!, :eql? + * # :hash, :<=>, :class, :singleton_class] + * k.methods.length #=> 57 */ VALUE diff --git a/marshal.c b/marshal.c index 808aa0f9af..03537395c8 100644 --- a/marshal.c +++ b/marshal.c @@ -876,7 +876,7 @@ clear_dump_arg(struct dump_arg *arg) * def initialize(str) * @str = str * end - * def sayHello + * def say_hello * @str * end * end @@ -886,7 +886,7 @@ clear_dump_arg(struct dump_arg *arg) * o = Klass.new("hello\n") * data = Marshal.dump(o) * obj = Marshal.load(data) - * obj.sayHello #=> "hello\n" + * obj.say_hello #=> "hello\n" * * Marshal can't dump following objects: * * anonymous Class/Module. diff --git a/proc.c b/proc.c index 18c7393536..f81118ae61 100644 --- a/proc.c +++ b/proc.c @@ -336,10 +336,10 @@ rb_binding_new(void) * calling +eval+ to execute the evaluated command in this * environment. Also see the description of class +Binding+. * - * def getBinding(param) + * def get_binding(param) * return binding * end - * b = getBinding("hello") + * b = get_binding("hello") * eval("param", b) #=> "hello" */ @@ -358,10 +358,10 @@ rb_f_binding(VALUE self) * lineno parameters are present, they will be used when * reporting syntax errors. * - * def getBinding(param) + * def get_binding(param) * return binding * end - * b = getBinding("hello") + * b = get_binding("hello") * b.eval("param") #=> "hello" */ @@ -2211,15 +2211,15 @@ Init_Proc(void) * def initialize(n) * @secret = n * end - * def getBinding + * def get_binding * return binding() * end * end * * k1 = Demo.new(99) - * b1 = k1.getBinding + * b1 = k1.get_binding * k2 = Demo.new(-3) - * b2 = k2.getBinding + * b2 = k2.get_binding * * eval("@secret", b1) #=> 99 * eval("@secret", b2) #=> -3 diff --git a/sample/biorhythm.rb b/sample/biorhythm.rb index 6465daa29f..7a8da7d124 100644 --- a/sample/biorhythm.rb +++ b/sample/biorhythm.rb @@ -29,13 +29,13 @@ require "date.rb" require "optparse" require "optparse/date" -def printHeader(y, m, d, p, w) +def print_header(y, m, d, p, w) print "\n>>> Biorhythm <<<\n" printf "The birthday %04d.%02d.%02d is a %s\n", y, m, d, w printf "Age in days: [%d]\n\n", p end -def getPosition(z) +def get_position(z) pi = Math::PI z = Integer(z) phys = (50.0 * (1.0 + sin((z / 23.0 - (z / 23)) * 360.0 * pi / 180.0))).to_i @@ -89,24 +89,24 @@ ausgabeart = options[:graph] ? "g" : "v" display_period = options[:days] if ausgabeart == "v" - printHeader(bd.year, bd.month, bd.day, dd - bd, bd.strftime("%a")) + print_header(bd.year, bd.month, bd.day, dd - bd, bd.strftime("%a")) print "\n" - phys, emot, geist = getPosition(dd - bd) + phys, emot, geist = get_position(dd - bd) printf "Biorhythm: %04d.%02d.%02d\n", dd.year, dd.month, dd.day printf "Physical: %d%%\n", phys printf "Emotional: %d%%\n", emot printf "Mental: %d%%\n", geist print "\n" else - printHeader(bd.year, bd.month, bd.day, dd - bd, bd.strftime("%a")) + print_header(bd.year, bd.month, bd.day, dd - bd, bd.strftime("%a")) print " P=physical, E=emotional, M=mental\n" print " -------------------------+-------------------------\n" print " Bad Condition | Good Condition\n" print " -------------------------+-------------------------\n" (dd - bd).step(dd - bd + display_period) do |z| - phys, emot, geist = getPosition(z) + phys, emot, geist = get_position(z) printf "%04d.%02d.%02d : ", dd.year, dd.month, dd.day p = (phys / 2.0 + 0.5).to_i diff --git a/vm_eval.c b/vm_eval.c index ce7057476c..54debd7fec 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -459,12 +459,12 @@ NORETURN(static void raise_method_missing(rb_thread_t *th, int argc, const VALUE * values. * * class Roman - * def romanToInt(str) + * def roman_to_int(str) * # ... * end * def method_missing(methId) * str = methId.id2name - * romanToInt(str) + * roman_to_int(str) * end * end * @@ -1082,12 +1082,12 @@ eval_string(VALUE self, VALUE src, VALUE scope, const char *file, int line) * optional filename and lineno parameters are * present, they will be used when reporting syntax errors. * - * def getBinding(str) + * def get_binding(str) * return binding * end * str = "hello" * eval "str + ' Fred'" #=> "hello Fred" - * eval "str + ' Fred'", getBinding("bye") #=> "bye Fred" + * eval "str + ' Fred'", get_binding("bye") #=> "bye Fred" */ VALUE diff --git a/vm_method.c b/vm_method.c index f7b7534830..278941aefa 100644 --- a/vm_method.c +++ b/vm_method.c @@ -1152,20 +1152,20 @@ top_private(int argc, VALUE *argv) * end * class Cls * include Mod - * def callOne + * def call_one * one * end * end * Mod.one #=> "This is one" * c = Cls.new - * c.callOne #=> "This is one" + * c.call_one #=> "This is one" * module Mod * def one * "This is the new one" * end * end * Mod.one #=> "This is one" - * c.callOne #=> "This is the new one" + * c.call_one #=> "This is the new one" */ static VALUE -- cgit v1.2.3