Class: AnkiTranslator::References::MerriamWebster
- Inherits:
-
Object
- Object
- AnkiTranslator::References::MerriamWebster
- Defined in:
- lib/vocab_to_anki/references/merriam_webster.rb
Instance Attribute Summary collapse
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
- #fetch_definitions(term) ⇒ Object
-
#initialize ⇒ MerriamWebster
constructor
A new instance of MerriamWebster.
Constructor Details
#initialize ⇒ MerriamWebster
Returns a new instance of MerriamWebster.
8 9 10 11 12 13 14 15 16 |
# File 'lib/vocab_to_anki/references/merriam_webster.rb', line 8 def initialize @name = :merriam_webster params = { key: AnkiTranslator.configuration.merriam_webster_api_key } headers = { "Content-Type" => "application/json" } @conn = Faraday.new(url: AnkiTranslator.configuration.merriam_webster_api_url, params: params, headers: headers) do |f| f.response :json end end |
Instance Attribute Details
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
6 7 8 |
# File 'lib/vocab_to_anki/references/merriam_webster.rb', line 6 def conn @conn end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/vocab_to_anki/references/merriam_webster.rb', line 6 def name @name end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
6 7 8 |
# File 'lib/vocab_to_anki/references/merriam_webster.rb', line 6 def session @session end |
Instance Method Details
#fetch_definitions(term) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/vocab_to_anki/references/merriam_webster.rb', line 18 def fetch_definitions(term) definitions = search(term) definitions.map do |d| Definition.new(text: d, source: name) end end |