-
-
Save anonymous/6e9afcc2d3f75cf0874535f27485f1d2 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
require 'httparty' | |
class API | |
def initialize | |
@endpoints = ['http://cnn.com', 'http://fox.com'] | |
end | |
def process | |
step_1 | |
end | |
def step_1 | |
puts "Start step 1 \n" | |
threads = [] | |
@endpoints.each {|endpoint| threads << Thread.new {get_request(endpoint)}} | |
threads.each {|thread| thread.join } | |
step_2 | |
end | |
def step_2 | |
puts "Start step 2 \n" | |
sleep(1) | |
puts "Finishing work in step 2 \n" | |
step_3 | |
end | |
def step_3 | |
puts "Start step 3 \n" | |
puts "Finishing work in step 3 \n" | |
end | |
def get_request(endpoint) | |
puts HTTParty.get(endpoint) | |
end | |
end | |
my_api = API.new() | |
my_api.process |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment