Sha256: b38d215cb7f8a5c2b7bac8ebe7faca943a648401ac4cf88f4ae4b963a7920fcc

Contents?: true

Size: 1.08 KB

Versions: 15

Compression:

Stored size: 1.08 KB

Contents

# HEY HACKER! THIS IS AN AUTO-GENERATED FILE.
# So don't bother editing it. To see how it's built, take a look at the Rakefile

module TagMethods

  # Fetches Words with a specific Tag.
  #
  def get_words_tagged(tag, *args)
    http_method = :get
    path = '/tag/{tag}/word'
    path.sub!('{tag}', tag.to_s)

    # Ruby turns all key-value arguments at the end into a single hash
    # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
    # becomes {:limit => 10, :part_of_speech => 'verb'}
    last_arg = args.pop if args.last.is_a?(Hash)
    last_arg = args.pop if args.last.is_a?(Array)
    last_arg ||= {}

    # Look for a kwarg called :request_only, whose presence indicates
    # that we want the request itself back, not the response body
    if last_arg.is_a?(Hash) && last_arg[:request_only].present?
      request_only = true
      last_arg.delete(:request_only)
    end

    params = last_arg
    body ||= {}
    request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
    request_only ? request : request.response.body
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
wordnik-4.12 lib/wordnik/resource_modules/tag.rb
wordnik-4.11 lib/wordnik/resource_modules/tag.rb
wordnik-4.10 lib/wordnik/resource_modules/tag.rb
wordnik-4.09 lib/wordnik/resource_modules/tag.rb
wordnik-4.08 lib/wordnik/resource_modules/tag.rb
wordnik-4.07 lib/wordnik/resource_modules/tag.rb
wordnik-4.06.15 lib/wordnik/resource_modules/tag.rb
wordnik-4.06.14 lib/wordnik/resource_modules/tag.rb
wordnik-4.06.13 lib/wordnik/resource_modules/tag.rb
wordnik-4.06.12 lib/wordnik/resource_modules/tag.rb
wordnik-4.06.11 lib/wordnik/resource_modules/tag.rb
wordnik-4.06.10 lib/wordnik/resource_modules/tag.rb
wordnik-4.06.08 lib/wordnik/resource_modules/tag.rb
wordnik-4.06.07 lib/wordnik/resource_modules/tag.rb
wordnik-4.06.06 lib/wordnik/resource_modules/tag.rb