{"action":"created","comment":{"url":"https://api.github.com/repos/fhasanaj/ruby/pulls/comments/60898281","id":60898281,"diff_hunk":"@@ -1,33 +1,44 @@\n-require_relative 'rosette_api_error'\n+require_relative 'bad_request_format_error'\n \n class DocumentParameters\n   attr_accessor :content, :content_uri, :file_path, :language\n \n-  def initialize(content=nil, content_uri=nil, file_path=nil, language=nil)\n-    @content = content\n-    @content_uri = content_uri\n-    @file_path = file_path\n-    @language = language\n+  def initialize(options = {})\n+    options = {\n+      'content' => nil,\n+      'content_uri' => nil,\n+      'file_path' => nil,\n+      'language' => nil\n+    }.update options\n+    @content = options['content']\n+    @content_uri = options['content_uri']\n+    @file_path = options['file_path']\n+    @language = options['language']\n   end\n \n   def validate_params\n-    if [@content, @content_uri, @file_path].count { |attr| !attr.nil? } > 1\n-      raise RosetteAPIError.new('badRequestFormat', 'The format of the request is invalid: multiple content sources;' \\\n-          ' must be one of an attachment, an inline \"content\" field, or an external \"contentUri\"')\n-    elsif [@content, @content_uri, @file_path].count { |attr| attr.nil? } == 3\n-      raise RosetteAPIError.new('badRequestFormat', 'The format of the request is invalid: no content provided; must' \\\n-          ' be one of an attachment, an inline \"content\" field, or an external \"contentUri\"')\n+    if [@content, @content_uri, @file_path].compact.length > 1\n+      raise BadRequestFormatError.new 'The format of the request is invalid: multiple content sources;' \\\n+                                      ' must be one of an attachment, an inline \"content\" field, or an external \"contentUri\"'\n+    elsif [@content, @content_uri, @file_path].all?(&:nil?)\n+      raise BadRequestFormatError.new 'The format of the request is invalid: no content provided; must' \\\n+                                      ' be one of an attachment, an inline \"content\" field, or an external \"contentUri\"'\n     end\n   end\n \n   def load_params\n-    validate_params\n-    self.to_hash.select { |k, v| !v.nil? }.map { |k, v| [k.to_s.split('_').collect(&:capitalize).join.sub!(/\\D/, &:downcase), v] }.to_h\n+    self.validate_params\n+    self.to_hash.select { |key, value| !value.nil? }\n+                .map { |key, value| [key.to_s.split('_').map(&:capitalize).join.sub!(/\\D/, &:downcase), value] }\n+                .to_h\n   end\n \n   def to_hash\n-    hash = {}\n-    instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }\n-    hash\n+    {","path":"document_parameters.rb","position":54,"original_position":54,"commit_id":"7db2b63d222aac48e13e65ca8f4908c9cd7d8f6e","original_commit_id":"7db2b63d222aac48e13e65ca8f4908c9cd7d8f6e","user":{"login":"jeremyday","id":7825,"avatar_url":"https://avatars.githubusercontent.com/u/7825?v=3","gravatar_id":"","url":"https://api.github.com/users/jeremyday","html_url":"https://github.com/jeremyday","followers_url":"https://api.github.com/users/jeremyday/followers","following_url":"https://api.github.com/users/jeremyday/following{/other_user}","gists_url":"https://api.github.com/users/jeremyday/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremyday/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremyday/subscriptions","organizations_url":"https://api.github.com/users/jeremyday/orgs","repos_url":"https://api.github.com/users/jeremyday/repos","events_url":"https://api.github.com/users/jeremyday/events{/privacy}","received_events_url":"https://api.github.com/users/jeremyday/received_events","type":"User","site_admin":false},"body":"This is slightly more code but also a much clearer way of creating the hash. I almost never have any need for `#instance_variables` and the related getters and setters.","created_at":"2016-04-25T11:25:18Z","updated_at":"2016-04-25T11:25:18Z","html_url":"https://github.com/fhasanaj/ruby/pull/1#discussion_r60898281","pull_request_url":"https://api.github.com/repos/fhasanaj/ruby/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/fhasanaj/ruby/pulls/comments/60898281"},"html":{"href":"https://github.com/fhasanaj/ruby/pull/1#discussion_r60898281"},"pull_request":{"href":"https://api.github.com/repos/fhasanaj/ruby/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/fhasanaj/ruby/pulls/1","id":67701157,"html_url":"https://github.com/fhasanaj/ruby/pull/1","diff_url":"https://github.com/fhasanaj/ruby/pull/1.diff","patch_url":"https://github.com/fhasanaj/ruby/pull/1.patch","issue_url":"https://api.github.com/repos/fhasanaj/ruby/issues/1","number":1,"state":"open","locked":false,"title":"I reworked the code using a few more common ruby idioms.","user":{"login":"jeremyday","id":7825,"avatar_url":"https://avatars.githubusercontent.com/u/7825?v=3","gravatar_id":"","url":"https://api.github.com/users/jeremyday","html_url":"https://github.com/jeremyday","followers_url":"https://api.github.com/users/jeremyday/followers","following_url":"https://api.github.com/users/jeremyday/following{/other_user}","gists_url":"https://api.github.com/users/jeremyday/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremyday/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremyday/subscriptions","organizations_url":"https://api.github.com/users/jeremyday/orgs","repos_url":"https://api.github.com/users/jeremyday/repos","events_url":"https://api.github.com/users/jeremyday/events{/privacy}","received_events_url":"https://api.github.com/users/jeremyday/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-25T11:04:03Z","updated_at":"2016-04-25T11:25:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"48553173224fcda3b7e80e3e6005c9b40efdf6e6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/fhasanaj/ruby/pulls/1/commits","review_comments_url":"https://api.github.com/repos/fhasanaj/ruby/pulls/1/comments","review_comment_url":"https://api.github.com/repos/fhasanaj/ruby/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fhasanaj/ruby/issues/1/comments","statuses_url":"https://api.github.com/repos/fhasanaj/ruby/statuses/7db2b63d222aac48e13e65ca8f4908c9cd7d8f6e","head":{"label":"jeremyday:RCB-373","ref":"RCB-373","sha":"7db2b63d222aac48e13e65ca8f4908c9cd7d8f6e","user":{"login":"jeremyday","id":7825,"avatar_url":"https://avatars.githubusercontent.com/u/7825?v=3","gravatar_id":"","url":"https://api.github.com/users/jeremyday","html_url":"https://github.com/jeremyday","followers_url":"https://api.github.com/users/jeremyday/followers","following_url":"https://api.github.com/users/jeremyday/following{/other_user}","gists_url":"https://api.github.com/users/jeremyday/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremyday/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremyday/subscriptions","organizations_url":"https://api.github.com/users/jeremyday/orgs","repos_url":"https://api.github.com/users/jeremyday/repos","events_url":"https://api.github.com/users/jeremyday/events{/privacy}","received_events_url":"https://api.github.com/users/jeremyday/received_events","type":"User","site_admin":false},"repo":{"id":56805925,"name":"ruby","full_name":"jeremyday/ruby","owner":{"login":"jeremyday","id":7825,"avatar_url":"https://avatars.githubusercontent.com/u/7825?v=3","gravatar_id":"","url":"https://api.github.com/users/jeremyday","html_url":"https://github.com/jeremyday","followers_url":"https://api.github.com/users/jeremyday/followers","following_url":"https://api.github.com/users/jeremyday/following{/other_user}","gists_url":"https://api.github.com/users/jeremyday/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremyday/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremyday/subscriptions","organizations_url":"https://api.github.com/users/jeremyday/orgs","repos_url":"https://api.github.com/users/jeremyday/repos","events_url":"https://api.github.com/users/jeremyday/events{/privacy}","received_events_url":"https://api.github.com/users/jeremyday/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jeremyday/ruby","description":"Ruby binding for the Rosette API","fork":true,"url":"https://api.github.com/repos/jeremyday/ruby","forks_url":"https://api.github.com/repos/jeremyday/ruby/forks","keys_url":"https://api.github.com/repos/jeremyday/ruby/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jeremyday/ruby/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jeremyday/ruby/teams","hooks_url":"https://api.github.com/repos/jeremyday/ruby/hooks","issue_events_url":"https://api.github.com/repos/jeremyday/ruby/issues/events{/number}","events_url":"https://api.github.com/repos/jeremyday/ruby/events","assignees_url":"https://api.github.com/repos/jeremyday/ruby/assignees{/user}","branches_url":"https://api.github.com/repos/jeremyday/ruby/branches{/branch}","tags_url":"https://api.github.com/repos/jeremyday/ruby/tags","blobs_url":"https://api.github.com/repos/jeremyday/ruby/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jeremyday/ruby/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jeremyday/ruby/git/refs{/sha}","trees_url":"https://api.github.com/repos/jeremyday/ruby/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jeremyday/ruby/statuses/{sha}","languages_url":"https://api.github.com/repos/jeremyday/ruby/languages","stargazers_url":"https://api.github.com/repos/jeremyday/ruby/stargazers","contributors_url":"https://api.github.com/repos/jeremyday/ruby/contributors","subscribers_url":"https://api.github.com/repos/jeremyday/ruby/subscribers","subscription_url":"https://api.github.com/repos/jeremyday/ruby/subscription","commits_url":"https://api.github.com/repos/jeremyday/ruby/commits{/sha}","git_commits_url":"https://api.github.com/repos/jeremyday/ruby/git/commits{/sha}","comments_url":"https://api.github.com/repos/jeremyday/ruby/comments{/number}","issue_comment_url":"https://api.github.com/repos/jeremyday/ruby/issues/comments{/number}","contents_url":"https://api.github.com/repos/jeremyday/ruby/contents/{+path}","compare_url":"https://api.github.com/repos/jeremyday/ruby/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jeremyday/ruby/merges","archive_url":"https://api.github.com/repos/jeremyday/ruby/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jeremyday/ruby/downloads","issues_url":"https://api.github.com/repos/jeremyday/ruby/issues{/number}","pulls_url":"https://api.github.com/repos/jeremyday/ruby/pulls{/number}","milestones_url":"https://api.github.com/repos/jeremyday/ruby/milestones{/number}","notifications_url":"https://api.github.com/repos/jeremyday/ruby/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jeremyday/ruby/labels{/name}","releases_url":"https://api.github.com/repos/jeremyday/ruby/releases{/id}","deployments_url":"https://api.github.com/repos/jeremyday/ruby/deployments","created_at":"2016-04-21T21:11:44Z","updated_at":"2016-01-27T17:37:53Z","pushed_at":"2016-04-24T16:44:38Z","git_url":"git://github.com/jeremyday/ruby.git","ssh_url":"git@github.com:jeremyday/ruby.git","clone_url":"https://github.com/jeremyday/ruby.git","svn_url":"https://github.com/jeremyday/ruby","homepage":null,"size":60,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"fhasanaj:RCB-373","ref":"RCB-373","sha":"181f0e5bb4d99b16f24bde6545657825d4d73a74","user":{"login":"fhasanaj","id":7769614,"avatar_url":"https://avatars.githubusercontent.com/u/7769614?v=3","gravatar_id":"","url":"https://api.github.com/users/fhasanaj","html_url":"https://github.com/fhasanaj","followers_url":"https://api.github.com/users/fhasanaj/followers","following_url":"https://api.github.com/users/fhasanaj/following{/other_user}","gists_url":"https://api.github.com/users/fhasanaj/gists{/gist_id}","starred_url":"https://api.github.com/users/fhasanaj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fhasanaj/subscriptions","organizations_url":"https://api.github.com/users/fhasanaj/orgs","repos_url":"https://api.github.com/users/fhasanaj/repos","events_url":"https://api.github.com/users/fhasanaj/events{/privacy}","received_events_url":"https://api.github.com/users/fhasanaj/received_events","type":"User","site_admin":false},"repo":{"id":51100089,"name":"ruby","full_name":"fhasanaj/ruby","owner":{"login":"fhasanaj","id":7769614,"avatar_url":"https://avatars.githubusercontent.com/u/7769614?v=3","gravatar_id":"","url":"https://api.github.com/users/fhasanaj","html_url":"https://github.com/fhasanaj","followers_url":"https://api.github.com/users/fhasanaj/followers","following_url":"https://api.github.com/users/fhasanaj/following{/other_user}","gists_url":"https://api.github.com/users/fhasanaj/gists{/gist_id}","starred_url":"https://api.github.com/users/fhasanaj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fhasanaj/subscriptions","organizations_url":"https://api.github.com/users/fhasanaj/orgs","repos_url":"https://api.github.com/users/fhasanaj/repos","events_url":"https://api.github.com/users/fhasanaj/events{/privacy}","received_events_url":"https://api.github.com/users/fhasanaj/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fhasanaj/ruby","description":"Ruby binding for the Rosette API","fork":true,"url":"https://api.github.com/repos/fhasanaj/ruby","forks_url":"https://api.github.com/repos/fhasanaj/ruby/forks","keys_url":"https://api.github.com/repos/fhasanaj/ruby/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fhasanaj/ruby/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fhasanaj/ruby/teams","hooks_url":"https://api.github.com/repos/fhasanaj/ruby/hooks","issue_events_url":"https://api.github.com/repos/fhasanaj/ruby/issues/events{/number}","events_url":"https://api.github.com/repos/fhasanaj/ruby/events","assignees_url":"https://api.github.com/repos/fhasanaj/ruby/assignees{/user}","branches_url":"https://api.github.com/repos/fhasanaj/ruby/branches{/branch}","tags_url":"https://api.github.com/repos/fhasanaj/ruby/tags","blobs_url":"https://api.github.com/repos/fhasanaj/ruby/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fhasanaj/ruby/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fhasanaj/ruby/git/refs{/sha}","trees_url":"https://api.github.com/repos/fhasanaj/ruby/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fhasanaj/ruby/statuses/{sha}","languages_url":"https://api.github.com/repos/fhasanaj/ruby/languages","stargazers_url":"https://api.github.com/repos/fhasanaj/ruby/stargazers","contributors_url":"https://api.github.com/repos/fhasanaj/ruby/contributors","subscribers_url":"https://api.github.com/repos/fhasanaj/ruby/subscribers","subscription_url":"https://api.github.com/repos/fhasanaj/ruby/subscription","commits_url":"https://api.github.com/repos/fhasanaj/ruby/commits{/sha}","git_commits_url":"https://api.github.com/repos/fhasanaj/ruby/git/commits{/sha}","comments_url":"https://api.github.com/repos/fhasanaj/ruby/comments{/number}","issue_comment_url":"https://api.github.com/repos/fhasanaj/ruby/issues/comments{/number}","contents_url":"https://api.github.com/repos/fhasanaj/ruby/contents/{+path}","compare_url":"https://api.github.com/repos/fhasanaj/ruby/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fhasanaj/ruby/merges","archive_url":"https://api.github.com/repos/fhasanaj/ruby/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fhasanaj/ruby/downloads","issues_url":"https://api.github.com/repos/fhasanaj/ruby/issues{/number}","pulls_url":"https://api.github.com/repos/fhasanaj/ruby/pulls{/number}","milestones_url":"https://api.github.com/repos/fhasanaj/ruby/milestones{/number}","notifications_url":"https://api.github.com/repos/fhasanaj/ruby/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fhasanaj/ruby/labels{/name}","releases_url":"https://api.github.com/repos/fhasanaj/ruby/releases{/id}","deployments_url":"https://api.github.com/repos/fhasanaj/ruby/deployments","created_at":"2016-02-04T19:34:12Z","updated_at":"2016-01-27T17:37:53Z","pushed_at":"2016-04-25T11:04:03Z","git_url":"git://github.com/fhasanaj/ruby.git","ssh_url":"git@github.com:fhasanaj/ruby.git","clone_url":"https://github.com/fhasanaj/ruby.git","svn_url":"https://github.com/fhasanaj/ruby","homepage":null,"size":57,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/fhasanaj/ruby/pulls/1"},"html":{"href":"https://github.com/fhasanaj/ruby/pull/1"},"issue":{"href":"https://api.github.com/repos/fhasanaj/ruby/issues/1"},"comments":{"href":"https://api.github.com/repos/fhasanaj/ruby/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/fhasanaj/ruby/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/fhasanaj/ruby/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fhasanaj/ruby/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/fhasanaj/ruby/statuses/7db2b63d222aac48e13e65ca8f4908c9cd7d8f6e"}}}}