Skip to content

Instantly share code, notes, and snippets.

@kouyaf77
Last active March 4, 2020 19:53
Show Gist options
  • Save kouyaf77/25e08fda0fe3cc9d4260c06c239f0835 to your computer and use it in GitHub Desktop.
Save kouyaf77/25e08fda0fe3cc9d4260c06c239f0835 to your computer and use it in GitHub Desktop.
GoodExampleXClient
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