Sha256: 11f9085fb68c81cd0785cab11b29eb75addcd4f89a20ff186bb9548483566d08
Contents?: true
Size: 492 Bytes
Versions: 2
Compression:
Stored size: 492 Bytes
Contents
# 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
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lexicorn-0.0.5 | lib/lexicorn/client.rb |
lexicorn-0.0.4 | lib/lexicorn/client.rb |