Created
August 17, 2016 19:37
-
-
Save brunojppb/a1e3bd34a2bcd558a430f487951b5a9b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'net/http' | |
require 'json' | |
def listar_usuarios(quantidade, my_proc) | |
uri = URI('http://jsonplaceholder.typicode.com/users') | |
response = Net::HTTP.get(uri) | |
JSON.parse(response) | |
my_proc.call(quantidade) | |
yield JSON.parse(response) if block_given? | |
puts "Finalizando listagem de usuarios" | |
end | |
debug = Proc.new { |variavel| puts "Debugando Variavel #{variavel}" } | |
listar_usuarios 10, debug do |response| | |
puts "Total de usuarios: #{response.size}" | |
end | |
listar_usuarios 10, debug |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment