Class: Lexicorn::Client
- Inherits:
-
Object
- Object
- Lexicorn::Client
- Defined in:
- lib/lexicorn/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Instance Method Summary collapse
- #find(word) ⇒ Object
-
#initialize(api_key) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(api_key) ⇒ Client
7 8 9 |
# File 'lib/lexicorn/client.rb', line 7 def initialize(api_key) @api_key = api_key end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
5 6 7 |
# File 'lib/lexicorn/client.rb', line 5 def api_key @api_key end |
Instance Method Details
#find(word) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/lexicorn/client.rb', line 11 def find(word) payload = UrlBuilder.build(word: word, api_key: @api_key) uri = URI(payload) JSON.parse(Net::HTTP.get(uri)).first['shortdef'] end |