I often have new code I'm trying to figure out, and constantly jumping back and forth between a console and a web browser with documentation sometimes really slows me down. Often times it's easy enough to remember which method you want just by seeing a list, even without detailed descriptions. Any object has a So, I'm trying a little experiment. I added this snippet to my class Object # print public methods which are not inherited from Object def pm (self.public_methods - Object.public_methods).sort end end pm method. So what?
Loading development environment (Rails 2.2.2) >> class Blah >> def foo; end >> def bar; end >> def blatz; end >> end => nil >> b = Blah.new => #<Blah:0x12b6b04> >> b.pm => ["bar", "blatz", "foo"] >> b.public_methods => ["returning", "to_yaml", "pretty_print_cycle", "inspect", "method_exists?", "stubs", "to_param", "extend_with_included_modules_from", "subclasses_of", "require_or_load", "clone", "method", "to_enum", "to_yaml_properties", "public_methods", "__metaclass__", "to_json", "suppress", "instance_variable_defined?", "instance_variable_names", "dclone", "equal?", "blatz", "freeze", "expects", "with_options", "foo", "methods", "respond_to?", "geometry_data_types", "instance_exec", "enable_warnings", "to_matcher", "to_query", "silence_warnings", "reset_mocha", "to_c", "dup", "enum_for", "instance_variables", "__id__", "copy_instance_variables_from", "duplicable?", "eql?", "object_id", "pretty_inspect", "require", "id", "send", "singleton_methods", "silence_stderr", "encode64", "class_eval", "taint", "taguri", "require_association", "stubba_method", "instance_variable_get", "frozen?", "instance_of?", "__send__", "require_library_or_gem", "b64encode", "to_a", "pretty_print", "taguri=", "daemonize", "remove_subclasses_of", "`", "type", "debugger", "blank?", "instance_eval", "protected_methods", "display", "==", "silence_stream", "unloadable", "decode64", "===", "acts_like?", "pm", "c", "to_yaml_style", "instance_variable_set", "extend", "kind_of?", "to_s", "extended_by", "class", "hash", "breakpoint", "present?", "mocha", "private_methods", "=~", "tainted?", "decode_b", "mocha_inspect", "instance_values", "untaint", "nil?", "load_with_new_constant_marking", "__is_a__", "bar", "stubba_object", "pretty_print_inspect", "require_dependency", "is_a?", "pretty_print_instance_variables", "metaclass"] See the difference? Call it micro-documentation. |
|||
Post new comment