Module: Dinosaurus
- Defined in:
- lib/dinosaurus/configuration.rb,
lib/dinosaurus.rb,
lib/dinosaurus/results.rb,
lib/dinosaurus/version.rb,
lib/dinosaurus/railties.rb,
lib/dinosaurus/thesaurus.rb
Overview
Enable setting and getting of configuration options.
Example:
This can now be used under config/initializers/dinosaurus.rb
Dinosaurus.configure do |config|
config.api_key = 'dfskljkf'
end
Defined Under Namespace
Classes: Configuration, MissingApiKeyError, Railties, RemoteServiceError, Results, Thesaurus
Constant Summary collapse
- VERSION =
"0.0.11"
Class Method Summary collapse
-
.antonyms_of(word) ⇒ Object
Convenience method to retrieve antonyms of a
word
. - .configuration ⇒ Object
- .configure {|configuration| ... } ⇒ Object
-
.lookup(word) ⇒ Object
Lookup a word in the Big Huge Thesaurus.
-
.related_to(word) ⇒ Object
Convenience method to retrieve terms which are related to the given
word
. -
.similar_to(word) ⇒ Object
Convenience method to retrieve similar terms to the given
word
. -
.synonyms_of(word) ⇒ Object
Convenience method to retrieve synonyms of a
word
.
Class Method Details
.antonyms_of(word) ⇒ Object
Convenience method to retrieve antonyms of a word
.
Dinosaurus.antonyms_of('people')
Returns an array.
35 36 37 38 |
# File 'lib/dinosaurus.rb', line 35 def self.antonyms_of(word) results = lookup(word) results.antonyms end |
.configuration ⇒ Object
21 22 23 |
# File 'lib/dinosaurus/configuration.rb', line 21 def self.configuration @configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
25 26 27 |
# File 'lib/dinosaurus/configuration.rb', line 25 def self.configure yield configuration end |
.lookup(word) ⇒ Object
Lookup a word in the Big Huge Thesaurus.
word
is expected to be a string. This method is a no-op if the word
is blank as defined by ActiveSupport.
Dinosaurus.lookup('people')
Returns an instance of Dinosaurus::Results
16 17 18 |
# File 'lib/dinosaurus.rb', line 16 def self.lookup(word) Dinosaurus::Thesaurus.lookup(word) end |
.related_to(word) ⇒ Object
Convenience method to retrieve terms which are related to the given word
.
Dinosaurus.('people')
Returns an array.
57 58 59 60 |
# File 'lib/dinosaurus.rb', line 57 def self.(word) results = lookup(word) results. end |
.similar_to(word) ⇒ Object
Convenience method to retrieve similar terms to the given word
.
Dinosaurus.similar_to('people')
Returns an array.
46 47 48 49 |
# File 'lib/dinosaurus.rb', line 46 def self.similar_to(word) results = lookup(word) results.similar_terms end |
.synonyms_of(word) ⇒ Object
Convenience method to retrieve synonyms of a word
.
Dinosaurus.synonyms_of('people')
Returns an array.
25 26 27 28 |
# File 'lib/dinosaurus.rb', line 25 def self.synonyms_of(word) results = lookup(word) results.synonyms end |