{"action":"created","comment":{"url":"https://api.github.com/repos/dockyard/styleguides/pulls/comments/24675900","id":24675900,"diff_hunk":"@@ -0,0 +1,609 @@\n+# Ruby Style Conventions\n+\n+## Table of Contents\n+  1.  [Whitespace](#whitespace)\n+      1. [Indentation](#indentation)\n+      1. [Inline](#inline)\n+      1. [Newlines](#newlines)\n+  1.  [Commenting](#commenting)\n+      1. [Commented-out code](#commented-out-code)\n+  1.  [Methods](#methods)\n+      1. [Method definitions](#method-definitions)\n+      1. [Method calls](#method-calls)\n+  1.  [Conditional Expressions](#conditional-expressions)\n+      1. [Conditional keywords](#conditional-keywords)\n+      1. [Ternary operator](#ternary-operator)\n+  1.  [Syntax](#syntax)\n+  1.  [Naming](#naming)\n+  1.  [Classes](#classes)\n+  1.  [Exceptions](#exceptions)\n+  1.  [Collections](#collections)\n+  1. [Strings](#strings)\n+  1. [Be Consistent](#be-consistent)\n+\n+## Whitespace\n+\n+### Indentation\n+\n+* Use soft-tabs set to 2 spaces.\n+\n+```ruby\n+class Pokemon\n+∙∙def weakness\n+∙∙∙∙# Handles weakness\n+  end\n+end\n+```\n+\n+### Inline\n+\n+* Never leave trailing whitespace.\n+\n+* Use spaces around operators; after commas, colons, and semicolons; and around\n+  `{` and before `}`.\n+\n+```ruby\n+sum = 1 + 1\n+a, b = 1, 2\n+a > sum ? '2 is now greater than 1' : 'You cannot math'\n+[1, 2, 3].each { |e| puts e }\n+```\n+\n+* No spaces after `(`, `[` or before `]`, `)`.\n+\n+```ruby\n+some(arg).other\n+[1, 2, 3].length\n+```\n+\n+### Newlines\n+\n+* Add a new line after conditionals, blocks, case statements, etc.\n+\n+```ruby\n+if wall.needs_paint?\n+  paint_the_wall\n+end\n+\n+wall.paint(:favorite_color)\n+```\n+\n+## Commenting\n+\n+> Though a pain to write, comments are absolutely vital to keeping our code\n+> readable. The following rules describe what you should comment and where. But\n+> remember: while comments are very important, the best code is\n+> self-documenting. Giving sensible names to types and variables is much better\n+> than using obscure names that you must then explain through comments.\n+\n+> When writing your comments, write for your audience: the next contributor who\n+> will need to understand your code. Be generous — the next one may be you!\n+\n+&mdash;[Google C++ Style Guide][google-c++]\n+\n+### Commented-out code\n+\n+Please don't leave commented-out code, Brian will personally hunt you down.\n+\n+## Methods\n+\n+### Method definitions\n+\n+* Use `def` with parentheses when there are arguments. Omit the\n+  parentheses when the method doesn't accept any arguments.\n+\n+```ruby\n+def some_method\n+  # body omitted\n+end\n+\n+def some_method_with_arguments(arg1, arg2)\n+  # body omitted\n+end\n+```\n+\n+* Do not use default arguments. Use an options hash instead.\n+\n+```ruby\n+# bad\n+def obliterate(things, gently = true, except = [], at = Time.now)\n+  ...\n+end\n+\n+def bake(pie, temp: 400, at = Time.now)\n+  # Bake stuff\n+end\n+\n+# good\n+def bake(pie, options = {})\n+  default_options = {\n+    temp: 400,\n+    :at => Time.now\n+  }\n+  options.reverse_merge!(default_options)\n+\n+  # Bake stuff\n+end\n+```\n+\n+### Method calls\n+\n+**Use parentheses** for a method call:\n+\n+* If the method returns a value.\n+\n+```ruby\n+# bad\n+@current_user = User.find_by_id 1964192\n+\n+# good\n+@current_user = User.find_by_id(1964192)\n+```\n+\n+* If the first argument to the method uses parentheses.\n+\n+```ruby\n+# bad\n+put! (x + y) % len, value\n+\n+# good\n+put!((x + y) % len, value)\n+```\n+\n+* Never put a space between a method name and the opening parenthesis.\n+\n+```ruby\n+# bad\n+f (3 + 2) + 1\n+\n+# good\n+f(3 + 2) + 1\n+```\n+\n+**Omit parentheses** for a method call if the method accepts no arguments.\n+\n+```ruby\n+# bad\n+nil?()\n+\n+# good\n+nil?\n+```\n+\n+If the method doesn't return a value (or we don't care about the return), parentheses are optional\n+(Especially if the arguments overflow to multiple lines, parentheses may add readability).\n+\n+```ruby\n+# okay\n+render(:partial => 'foo')\n+\n+# okay\n+render :partial => 'foo'\n+```\n+\n+In either case:\n+\n+* If a method accepts an options hash as the last argument, do not use `{` `}`\n+  during invocation.\n+\n+```ruby\n+# bad\n+get '/v1/reservations', { :id => 54875 }\n+\n+# good\n+get '/v1/reservations', id: 54875\n+```\n+\n+## Conditional Expressions\n+\n+### Conditional keywords\n+\n+* Never use `then` for multi-line `if/unless`.\n+\n+```ruby\n+# bad\n+if some_condition then\n+  ...\n+end\n+\n+# good\n+if some_condition\n+  ...\n+end\n+```\n+\n+* The `and` and `or` keywords are banned. It's just not worth it. Always use `&&` and `||` instead.","path":"ruby.md","position":215,"original_position":215,"commit_id":"644c25051f47a3daf762914cb7432fbece27b019","original_commit_id":"644c25051f47a3daf762914cb7432fbece27b019","user":{"login":"danmcclain","id":144138,"avatar_url":"https://avatars.githubusercontent.com/u/144138?v=3","gravatar_id":"","url":"https://api.github.com/users/danmcclain","html_url":"https://github.com/danmcclain","followers_url":"https://api.github.com/users/danmcclain/followers","following_url":"https://api.github.com/users/danmcclain/following{/other_user}","gists_url":"https://api.github.com/users/danmcclain/gists{/gist_id}","starred_url":"https://api.github.com/users/danmcclain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danmcclain/subscriptions","organizations_url":"https://api.github.com/users/danmcclain/orgs","repos_url":"https://api.github.com/users/danmcclain/repos","events_url":"https://api.github.com/users/danmcclain/events{/privacy}","received_events_url":"https://api.github.com/users/danmcclain/received_events","type":"User","site_admin":false},"body":"I would state why (order of precedence)","created_at":"2015-02-13T16:28:35Z","updated_at":"2015-02-13T16:28:35Z","html_url":"https://github.com/dockyard/styleguides/pull/14#discussion_r24675900","pull_request_url":"https://api.github.com/repos/dockyard/styleguides/pulls/14","_links":{"self":{"href":"https://api.github.com/repos/dockyard/styleguides/pulls/comments/24675900"},"html":{"href":"https://github.com/dockyard/styleguides/pull/14#discussion_r24675900"},"pull_request":{"href":"https://api.github.com/repos/dockyard/styleguides/pulls/14"}}},"pull_request":{"url":"https://api.github.com/repos/dockyard/styleguides/pulls/14","id":28834157,"html_url":"https://github.com/dockyard/styleguides/pull/14","diff_url":"https://github.com/dockyard/styleguides/pull/14.diff","patch_url":"https://github.com/dockyard/styleguides/pull/14.patch","issue_url":"https://api.github.com/repos/dockyard/styleguides/issues/14","number":14,"state":"open","locked":false,"title":"First draft of the Ruby guide","user":{"login":"duggiefresh","id":1206678,"avatar_url":"https://avatars.githubusercontent.com/u/1206678?v=3","gravatar_id":"","url":"https://api.github.com/users/duggiefresh","html_url":"https://github.com/duggiefresh","followers_url":"https://api.github.com/users/duggiefresh/followers","following_url":"https://api.github.com/users/duggiefresh/following{/other_user}","gists_url":"https://api.github.com/users/duggiefresh/gists{/gist_id}","starred_url":"https://api.github.com/users/duggiefresh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duggiefresh/subscriptions","organizations_url":"https://api.github.com/users/duggiefresh/orgs","repos_url":"https://api.github.com/users/duggiefresh/repos","events_url":"https://api.github.com/users/duggiefresh/events{/privacy}","received_events_url":"https://api.github.com/users/duggiefresh/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-06T19:19:13Z","updated_at":"2015-02-13T16:28:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5c47509eda9a36b07b20f34077a1ba13a3ea5983","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dockyard/styleguides/pulls/14/commits","review_comments_url":"https://api.github.com/repos/dockyard/styleguides/pulls/14/comments","review_comment_url":"https://api.github.com/repos/dockyard/styleguides/pulls/comments/{number}","comments_url":"https://api.github.com/repos/dockyard/styleguides/issues/14/comments","statuses_url":"https://api.github.com/repos/dockyard/styleguides/statuses/644c25051f47a3daf762914cb7432fbece27b019","head":{"label":"dockyard:ruby-guide","ref":"ruby-guide","sha":"644c25051f47a3daf762914cb7432fbece27b019","user":{"login":"dockyard","id":873981,"avatar_url":"https://avatars.githubusercontent.com/u/873981?v=3","gravatar_id":"","url":"https://api.github.com/users/dockyard","html_url":"https://github.com/dockyard","followers_url":"https://api.github.com/users/dockyard/followers","following_url":"https://api.github.com/users/dockyard/following{/other_user}","gists_url":"https://api.github.com/users/dockyard/gists{/gist_id}","starred_url":"https://api.github.com/users/dockyard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dockyard/subscriptions","organizations_url":"https://api.github.com/users/dockyard/orgs","repos_url":"https://api.github.com/users/dockyard/repos","events_url":"https://api.github.com/users/dockyard/events{/privacy}","received_events_url":"https://api.github.com/users/dockyard/received_events","type":"Organization","site_admin":false},"repo":{"id":29650939,"name":"styleguides","full_name":"dockyard/styleguides","owner":{"login":"dockyard","id":873981,"avatar_url":"https://avatars.githubusercontent.com/u/873981?v=3","gravatar_id":"","url":"https://api.github.com/users/dockyard","html_url":"https://github.com/dockyard","followers_url":"https://api.github.com/users/dockyard/followers","following_url":"https://api.github.com/users/dockyard/following{/other_user}","gists_url":"https://api.github.com/users/dockyard/gists{/gist_id}","starred_url":"https://api.github.com/users/dockyard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dockyard/subscriptions","organizations_url":"https://api.github.com/users/dockyard/orgs","repos_url":"https://api.github.com/users/dockyard/repos","events_url":"https://api.github.com/users/dockyard/events{/privacy}","received_events_url":"https://api.github.com/users/dockyard/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dockyard/styleguides","description":"Styleguides for DockYard","fork":false,"url":"https://api.github.com/repos/dockyard/styleguides","forks_url":"https://api.github.com/repos/dockyard/styleguides/forks","keys_url":"https://api.github.com/repos/dockyard/styleguides/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dockyard/styleguides/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dockyard/styleguides/teams","hooks_url":"https://api.github.com/repos/dockyard/styleguides/hooks","issue_events_url":"https://api.github.com/repos/dockyard/styleguides/issues/events{/number}","events_url":"https://api.github.com/repos/dockyard/styleguides/events","assignees_url":"https://api.github.com/repos/dockyard/styleguides/assignees{/user}","branches_url":"https://api.github.com/repos/dockyard/styleguides/branches{/branch}","tags_url":"https://api.github.com/repos/dockyard/styleguides/tags","blobs_url":"https://api.github.com/repos/dockyard/styleguides/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dockyard/styleguides/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dockyard/styleguides/git/refs{/sha}","trees_url":"https://api.github.com/repos/dockyard/styleguides/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dockyard/styleguides/statuses/{sha}","languages_url":"https://api.github.com/repos/dockyard/styleguides/languages","stargazers_url":"https://api.github.com/repos/dockyard/styleguides/stargazers","contributors_url":"https://api.github.com/repos/dockyard/styleguides/contributors","subscribers_url":"https://api.github.com/repos/dockyard/styleguides/subscribers","subscription_url":"https://api.github.com/repos/dockyard/styleguides/subscription","commits_url":"https://api.github.com/repos/dockyard/styleguides/commits{/sha}","git_commits_url":"https://api.github.com/repos/dockyard/styleguides/git/commits{/sha}","comments_url":"https://api.github.com/repos/dockyard/styleguides/comments{/number}","issue_comment_url":"https://api.github.com/repos/dockyard/styleguides/issues/comments/{number}","contents_url":"https://api.github.com/repos/dockyard/styleguides/contents/{+path}","compare_url":"https://api.github.com/repos/dockyard/styleguides/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dockyard/styleguides/merges","archive_url":"https://api.github.com/repos/dockyard/styleguides/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dockyard/styleguides/downloads","issues_url":"https://api.github.com/repos/dockyard/styleguides/issues{/number}","pulls_url":"https://api.github.com/repos/dockyard/styleguides/pulls{/number}","milestones_url":"https://api.github.com/repos/dockyard/styleguides/milestones{/number}","notifications_url":"https://api.github.com/repos/dockyard/styleguides/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dockyard/styleguides/labels{/name}","releases_url":"https://api.github.com/repos/dockyard/styleguides/releases{/id}","created_at":"2015-01-22T03:34:12Z","updated_at":"2015-01-23T17:26:02Z","pushed_at":"2015-02-10T15:01:57Z","git_url":"git://github.com/dockyard/styleguides.git","ssh_url":"git@github.com:dockyard/styleguides.git","clone_url":"https://github.com/dockyard/styleguides.git","svn_url":"https://github.com/dockyard/styleguides","homepage":null,"size":526,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":13,"forks":0,"open_issues":13,"watchers":0,"default_branch":"master"}},"base":{"label":"dockyard:master","ref":"master","sha":"23d1f53afb740802f7d7e6d5d0c041d897d10e3b","user":{"login":"dockyard","id":873981,"avatar_url":"https://avatars.githubusercontent.com/u/873981?v=3","gravatar_id":"","url":"https://api.github.com/users/dockyard","html_url":"https://github.com/dockyard","followers_url":"https://api.github.com/users/dockyard/followers","following_url":"https://api.github.com/users/dockyard/following{/other_user}","gists_url":"https://api.github.com/users/dockyard/gists{/gist_id}","starred_url":"https://api.github.com/users/dockyard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dockyard/subscriptions","organizations_url":"https://api.github.com/users/dockyard/orgs","repos_url":"https://api.github.com/users/dockyard/repos","events_url":"https://api.github.com/users/dockyard/events{/privacy}","received_events_url":"https://api.github.com/users/dockyard/received_events","type":"Organization","site_admin":false},"repo":{"id":29650939,"name":"styleguides","full_name":"dockyard/styleguides","owner":{"login":"dockyard","id":873981,"avatar_url":"https://avatars.githubusercontent.com/u/873981?v=3","gravatar_id":"","url":"https://api.github.com/users/dockyard","html_url":"https://github.com/dockyard","followers_url":"https://api.github.com/users/dockyard/followers","following_url":"https://api.github.com/users/dockyard/following{/other_user}","gists_url":"https://api.github.com/users/dockyard/gists{/gist_id}","starred_url":"https://api.github.com/users/dockyard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dockyard/subscriptions","organizations_url":"https://api.github.com/users/dockyard/orgs","repos_url":"https://api.github.com/users/dockyard/repos","events_url":"https://api.github.com/users/dockyard/events{/privacy}","received_events_url":"https://api.github.com/users/dockyard/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dockyard/styleguides","description":"Styleguides for DockYard","fork":false,"url":"https://api.github.com/repos/dockyard/styleguides","forks_url":"https://api.github.com/repos/dockyard/styleguides/forks","keys_url":"https://api.github.com/repos/dockyard/styleguides/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dockyard/styleguides/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dockyard/styleguides/teams","hooks_url":"https://api.github.com/repos/dockyard/styleguides/hooks","issue_events_url":"https://api.github.com/repos/dockyard/styleguides/issues/events{/number}","events_url":"https://api.github.com/repos/dockyard/styleguides/events","assignees_url":"https://api.github.com/repos/dockyard/styleguides/assignees{/user}","branches_url":"https://api.github.com/repos/dockyard/styleguides/branches{/branch}","tags_url":"https://api.github.com/repos/dockyard/styleguides/tags","blobs_url":"https://api.github.com/repos/dockyard/styleguides/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dockyard/styleguides/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dockyard/styleguides/git/refs{/sha}","trees_url":"https://api.github.com/repos/dockyard/styleguides/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dockyard/styleguides/statuses/{sha}","languages_url":"https://api.github.com/repos/dockyard/styleguides/languages","stargazers_url":"https://api.github.com/repos/dockyard/styleguides/stargazers","contributors_url":"https://api.github.com/repos/dockyard/styleguides/contributors","subscribers_url":"https://api.github.com/repos/dockyard/styleguides/subscribers","subscription_url":"https://api.github.com/repos/dockyard/styleguides/subscription","commits_url":"https://api.github.com/repos/dockyard/styleguides/commits{/sha}","git_commits_url":"https://api.github.com/repos/dockyard/styleguides/git/commits{/sha}","comments_url":"https://api.github.com/repos/dockyard/styleguides/comments{/number}","issue_comment_url":"https://api.github.com/repos/dockyard/styleguides/issues/comments/{number}","contents_url":"https://api.github.com/repos/dockyard/styleguides/contents/{+path}","compare_url":"https://api.github.com/repos/dockyard/styleguides/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dockyard/styleguides/merges","archive_url":"https://api.github.com/repos/dockyard/styleguides/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dockyard/styleguides/downloads","issues_url":"https://api.github.com/repos/dockyard/styleguides/issues{/number}","pulls_url":"https://api.github.com/repos/dockyard/styleguides/pulls{/number}","milestones_url":"https://api.github.com/repos/dockyard/styleguides/milestones{/number}","notifications_url":"https://api.github.com/repos/dockyard/styleguides/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dockyard/styleguides/labels{/name}","releases_url":"https://api.github.com/repos/dockyard/styleguides/releases{/id}","created_at":"2015-01-22T03:34:12Z","updated_at":"2015-01-23T17:26:02Z","pushed_at":"2015-02-10T15:01:57Z","git_url":"git://github.com/dockyard/styleguides.git","ssh_url":"git@github.com:dockyard/styleguides.git","clone_url":"https://github.com/dockyard/styleguides.git","svn_url":"https://github.com/dockyard/styleguides","homepage":null,"size":526,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":13,"forks":0,"open_issues":13,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dockyard/styleguides/pulls/14"},"html":{"href":"https://github.com/dockyard/styleguides/pull/14"},"issue":{"href":"https://api.github.com/repos/dockyard/styleguides/issues/14"},"comments":{"href":"https://api.github.com/repos/dockyard/styleguides/issues/14/comments"},"review_comments":{"href":"https://api.github.com/repos/dockyard/styleguides/pulls/14/comments"},"review_comment":{"href":"https://api.github.com/repos/dockyard/styleguides/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/dockyard/styleguides/pulls/14/commits"},"statuses":{"href":"https://api.github.com/repos/dockyard/styleguides/statuses/644c25051f47a3daf762914cb7432fbece27b019"}}}}