Method: WordMethods#get_comment_on_word
- Defined in:
- lib/wordnik/resource_modules/word.rb
#get_comment_on_word(word, commentId, *args) ⇒ Object
Fetches a Comment by ID
1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 |
# File 'lib/wordnik/resource_modules/word.rb', line 1007 def get_comment_on_word(word, commentId, *args) http_method = :get path = '/word/{word}/comment/{commentId}' path.sub!('{word}', word.to_s) path.sub!('{commentId}', commentId.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 |