Skip to content

Instantly share code, notes, and snippets.

@JRJurman
Last active December 12, 2015 03:18
Show Gist options
  • Select an option

  • Save JRJurman/4705231 to your computer and use it in GitHub Desktop.

Select an option

Save JRJurman/4705231 to your computer and use it in GitHub Desktop.
META PROGRAMMING!
class Meta_Buffer
def save
puts "no modifications"
end
def read
""
end
def write( str )
eval("
def save
def save
puts \"no modifications\"
end
def read
\"#{read + str}\"
end
end
")
end
end
@JRJurman
Copy link
Copy Markdown
Author

JRJurman commented Feb 4, 2013

The eval lets me write a hard coded method with the arguments passed in through write( str ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment