Skip to content

Instantly share code, notes, and snippets.

@Mon-Ouie
Created September 12, 2014 19:18
Show Gist options
  • Save Mon-Ouie/d3c3478552f230bfeaf3 to your computer and use it in GitHub Desktop.
Save Mon-Ouie/d3c3478552f230bfeaf3 to your computer and use it in GitHub Desktop.
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