# frozen_string_literal: true module Lexicorn class Client attr_reader :api_key def initialize(api_key) @api_key = api_key end def find(word) payload = UrlBuilder.build(word: word, api_key: @api_key) uri = URI(payload) JSON.parse(Net::HTTP.get(uri)).first['shortdef'] end end module_function # Instead of Lexicorn::Client.new, you could do: # Lexicorn.new which is less verbose def new(api_key) Client.new(api_key) end end