Skip to content

Instantly share code, notes, and snippets.

@krames
Last active December 15, 2015 07:29
Show Gist options
  • Select an option

  • Save krames/5223624 to your computer and use it in GitHub Desktop.

Select an option

Save krames/5223624 to your computer and use it in GitHub Desktop.
Code snippet use to generate rdoc information from Excon::Response
def print_section(obj, i=2)
return if obj.nil?
obj.each_pair do |k, v|
klass = v.nil? ? String : v.class
print " " * i
puts "* '#{k}'<~#{klass}>: -"
print_section(v, i + 1) if v.is_a?(Hash)
print_section(v.first, i + 1) if v.is_a?(Array)
end
end
def print_doc(response, methods=[:headers, :body])
methods.each do |method|
section = response.send method
next if section.is_a? String
puts " * #{method}<~#{section.class}>:"
print_section section
end
nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment