From 9276e678a0de4f02fe705c7ca35eea4706be6746 Mon Sep 17 00:00:00 2001 From: Andrew Grimm Date: Sat, 5 Mar 2011 23:20:22 +1100 Subject: [PATCH] Fix camel case method names in documentation examples. --- class.c | 10 +++++----- marshal.c | 4 ++-- proc.c | 14 +++++++------- sample/biorhythm.rb | 12 ++++++------ vm_eval.c | 8 ++++---- vm_method.c | 6 +++--- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/class.c b/class.c index 0d76233..39e5e14 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 808aa0f..0353739 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 18c7393..f81118a 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 6465daa..7a8da7d 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 ce70574..54debd7 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 f7b7534..278941a 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 -- 1.6.6