Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
Learn How to Create Your Own Programming Language
createyourproglang.com
Recent
Simple Particle Engine for a shooter game
Snake / Nibbles clone in C and Ncurses
Please improve
Parsing of XML data has high CPU usage
Convert simple Javascript to jQuery plugin
Active Record getting unique records
List the files in a directory without the directory name or the extension
clean the code
ohs system, recruitment software, hr software, oh&s software, human resources software, ohs software
Array parsing in a block
Popular
Parsing of XML data has high CPU usage
Please improve
Snake / Nibbles clone in C and Ncurses
List the files in a directory without the directory name or the extension
Convert simple Javascript to jQuery plugin
Simple Particle Engine for a shooter game
Active Record getting unique records
Breadth first cartesian product iterator
php refactoring
first BST
Pastable version of
Refactor "class << self" into module
<pre class='prettyprint' language='ruby'>module StringReader def string_reader(*params) params.each do |param| variable_name = "@" + param.to_s define_method(param) do self.instance_variable_get(variable_name).to_s end end end end class MyClass class << self include StringReader end string_reader :foo def initialize @foo = 42 end end require "pp" my = MyClass.new pp my.foo #=> "42" (a string) # I would like to re-write the MyClass definition to: # # class MyClass # include StringReader # # string_reader :foo # # def initialize # @foo = 42 # end # end # # How do I refactor StringReader to get this code?</pre> <a href="http://www.refactormycode.com/codes/311-refactor-class-self-into-module" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://www.refactormycode.com/images/small_logo.gif" style="border:0" /></a>