Created
September 12, 2014 19:18
-
-
Save Mon-Ouie/d3c3478552f230bfeaf3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def pretty_print_attributes(q, attributes) | |
id = "%x" % (__id__ * 2) | |
id.sub!(/\Af(?=[[:xdigit:]]{2}+\z)/, '') if id.sub!(/\A\.\./, '') | |
klass = self.class.pretty_inspect.chomp | |
q.group(2, "\#<#{klass}:0x#{id}", '>') do | |
q.seplist(attributes, lambda { q.text ',' }) do |key| | |
q.breakable | |
q.text key.to_s | |
q.text '=' | |
q.group(2) do | |
q.breakable '' | |
q.pp send(key) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment