Last active
March 4, 2020 19:53
-
-
Save kouyaf77/25e08fda0fe3cc9d4260c06c239f0835 to your computer and use it in GitHub Desktop.
GoodExampleXClient
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 'net/http' | |
require 'uri' | |
class GoodExampleXClient | |
DEFAULT_URL = 'https://example.com'.freeze | |
def get(url=DEFAULT_URL) | |
r = Net::HTTP.get_response(URI.parse(url)) | |
Response.new(r.body, r.code) | |
end | |
class Response | |
attr_reader :body, :status | |
def initialize(body, status) | |
@body = body | |
@status = status | |
end | |
def success? | |
status == '200' | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment