{"action":"created","comment":{"url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/pulls/comments/43838656","id":43838656,"diff_hunk":"@@ -0,0 +1,190 @@\n+#Ruby <3's OOP\n+\n+##Learning Objectives\n+By the end of lesson, students will be able to...\n+\n+* Distinguish between objects & classes in Ruby\n+* Initialize classes\n+* Define attributes & instance methods\n+* Distinguish between instance and class variables\n+\n+##Hashes (10m)\n+\n+Let's create a new Hash\n+\n+* Hashes are simple key/value stores.\n+\n+**Challenge:**\n+How can I organize my data using key/value pairs in Ruby? Like so:\n+\n+```ruby\n+# hash rocket notation\n+hash = {\"name\"=>\"Napoleon\", \"fav_food\"=>\"steak\", \"skills\"=>[\"archery\", \"combat\", \"egg farming\"]}\n+hash[\"name\"] #=> \"Napoleon\"\n+hash['skills'].first #=> \"archery\"\n+test =  { 0 => \"Zero\", 1 => \"One\", 2 => \"Two\" }\n+test[0] #=> \"Zero\"\n+\n+# symbol notation\n+{name: \"James Bond\", fav_food: \"Vodka Martini\",\n+skills: [\"hand to hand combat\", \"marksmanship\", \"espionage\"]}\n+```\n+\n+##Objects (10m)\n+\n+- Everything in Ruby is an Object; however, we almost never use plain vanilla Objects because there are more sophisticated implementations of them such a `String`, `Array`, `Integer`, and `Hash`.\n+\n+- Different objects provide different types of functionality for storing data and performing behaviors. However, for more complex applications, classes (a certain kind of object) are used to model real-world interactions.\n+\n+**Challenge:**\n+How can we prove that the Hash we just created inherited from `Basic Object`?\n+\n+*Hint:* use the #is_a? method\n+\n+\n+###Class Inheritance Tree\n+\n+![Class inheritance](http://i.stack.imgur.com/rvcEi.png)\n+\n+##Classes (10m)\n+\n+**Challenge:**\n+How do we create a class in Ruby?\n+\n+Goal: Let's create a Car that goes \"Vroom\" when it's first *initialized*\n+\n+*Refresher: Classes are datatypes used to create more data. They are analogous to constructors in JavaScript.*\n+\n+##Attributes (10m)\n+\n+What should we do if we want to set attributes on the car, such as a paint color and year?\n+\n+**Challenge:**\n+Enable this code...\n+\n+```ruby\n+fiat = Car.new\n+fiat.color = \"hot pink\"\n+fiat.color\n+=> \"hot pink\"\n+```\n+\n+*Hint: Use `attr_accessor`.*\n+\n+*Bonus: Don't use `attr_accessor`*\n+\n+##Methods (10m)\n+\n+**Challenge:**\n+How would we create an instance method for Car named `color?`, which tests whether the color matches what is passed in?\n+\n+```ruby\n+alpha = Car.new\n+alpha.color = \"orange\"\n+alpha.color?(\"blue\")\n+=> false\n+alpha.color?(\"orange\")\n+=> true\n+```\n+\n+*Hint: define a new method with the `def` keyword inside the class*\n+\n+##Initialization & Instance Variables (10m)\n+\n+**Challenge:**\n+What If I want to set the color of the car at the moment I'm creating it? How could I enable code like this?\n+\n+```ruby\n+lambo = Car.new(\"red\")\n+lambo.color\n+=> \"red\"\n+```\n+\n+*Hint: Create an instance variable with `@`*\n+\n+##Class Variables (10m)\n+\n+What if I wanted a running counter for all the cars I've ever created? Enable the code: `Car.total` which outputs the total number of all cars ever created.\n+\n+*Hint: Create a class variable with `@@` to store the count and use the `self` keyword to add a class method*\n+\n+*Note: Class variables are used much more infrequently than instance variables*\n+\n+## Quick Review (15m)\n+\n+Think, pair, share...\n+\n+  * What is a class?\n+    - What is an attribute?\n+    - What is a method?\n+  * What is the difference between:\n+    - an instance variable,\n+    - a class variable\n+  * Why do we use classes?\n+  * What is inheritance?\n+\n+## Inheritance (25m)\n+\n+Given an `Vehicle` class that contains the method `accelerate` & attribute `speed`..\n+\n+```ruby\n+class Vehicle\n+  attr_accessor :speed\n+  def initialize\n+  \t@speed = 0\n+  end\n+  def accelerate(speed)\n+  \t@speed += speed\n+  end\n+end\n+```\n+\n+**Challenge:**\n+How can I create both `Car` and `Motorbike` classes while being DRY and not duplicating the method `accelerate` in each?\n+\n+## Exercise: Characters and Superheroes\n+\n+Previously you worked with using inheritance to create some `Animal` and `People` classes. This exercise will review those concepts, using the `Character` and `Superhero` classes.\n+\n+Superheroes are still Characters after all. In this exercise, you'll define:\n+\n+  1. A `Character` class, with the following:\n+    * Attributes (instance variables defined in initialize method):\n+      * `name`: A string that holds the character's name\n+    * Instance Methods:\n+      * `location`: Takes a parameter `origin` prints out a message telling the character's `name` and where they are from (their `origin`)\n+      * `exercise` & `rest`: These two methods should NOT be passed any arguments. Instead, they will set an instance variable `@state` to the string `\"ready\"` or `\"tired\"` respectively.\n+    - *Note:* What type of `attr` method will be needed to `read` the name and state variables?\n+\n+  2. A `Superhero` class, with the following characteristics:\n+    * Inherits from `Character`\n+    * Adds 2 new instance variables (which initialize takes as arguments):\n+      * `charisma`\n+      * `secret_identity`\n+    * initializes using `super`, passing `name` as an argument\n+    - Adds 2 new methods:\n+      - `persuade`, which\n+        - takes another character as an argument","path":"w06-ruby-on-rails/d3-dawn-ruby-oop/README.md","position":176,"original_position":167,"commit_id":"f26b690a546b3d09b461b541034086181fa5d5b3","original_commit_id":"49d55dcad6c28f63da928f5b694768f21fc66e20","user":{"login":"tgaff","id":1916144,"avatar_url":"https://avatars.githubusercontent.com/u/1916144?v=3","gravatar_id":"","url":"https://api.github.com/users/tgaff","html_url":"https://github.com/tgaff","followers_url":"https://api.github.com/users/tgaff/followers","following_url":"https://api.github.com/users/tgaff/following{/other_user}","gists_url":"https://api.github.com/users/tgaff/gists{/gist_id}","starred_url":"https://api.github.com/users/tgaff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgaff/subscriptions","organizations_url":"https://api.github.com/users/tgaff/orgs","repos_url":"https://api.github.com/users/tgaff/repos","events_url":"https://api.github.com/users/tgaff/events{/privacy}","received_events_url":"https://api.github.com/users/tgaff/received_events","type":"User","site_admin":false},"body":"Maybe \"an instance of another character\" ","created_at":"2015-11-04T03:08:09Z","updated_at":"2015-11-04T03:08:09Z","html_url":"https://github.com/sf-wdi-22-23/modules-23/pull/74#discussion_r43838656","pull_request_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/pulls/74","_links":{"self":{"href":"https://api.github.com/repos/sf-wdi-22-23/modules-23/pulls/comments/43838656"},"html":{"href":"https://github.com/sf-wdi-22-23/modules-23/pull/74#discussion_r43838656"},"pull_request":{"href":"https://api.github.com/repos/sf-wdi-22-23/modules-23/pulls/74"}}},"pull_request":{"url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/pulls/74","id":49514100,"html_url":"https://github.com/sf-wdi-22-23/modules-23/pull/74","diff_url":"https://github.com/sf-wdi-22-23/modules-23/pull/74.diff","patch_url":"https://github.com/sf-wdi-22-23/modules-23/pull/74.patch","issue_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/issues/74","number":74,"state":"open","locked":false,"title":"D3 dawn ruby oop","user":{"login":"mtvillwock","id":8475488,"avatar_url":"https://avatars.githubusercontent.com/u/8475488?v=3","gravatar_id":"","url":"https://api.github.com/users/mtvillwock","html_url":"https://github.com/mtvillwock","followers_url":"https://api.github.com/users/mtvillwock/followers","following_url":"https://api.github.com/users/mtvillwock/following{/other_user}","gists_url":"https://api.github.com/users/mtvillwock/gists{/gist_id}","starred_url":"https://api.github.com/users/mtvillwock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtvillwock/subscriptions","organizations_url":"https://api.github.com/users/mtvillwock/orgs","repos_url":"https://api.github.com/users/mtvillwock/repos","events_url":"https://api.github.com/users/mtvillwock/events{/privacy}","received_events_url":"https://api.github.com/users/mtvillwock/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-11-03T02:42:16Z","updated_at":"2015-11-04T03:08:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6eb226d72f0aba4e62ce404c918bed2b869567a0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/pulls/74/commits","review_comments_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/pulls/74/comments","review_comment_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/issues/74/comments","statuses_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/statuses/f26b690a546b3d09b461b541034086181fa5d5b3","head":{"label":"sf-wdi-22-23:d3-dawn-ruby-oop","ref":"d3-dawn-ruby-oop","sha":"f26b690a546b3d09b461b541034086181fa5d5b3","user":{"login":"sf-wdi-22-23","id":14679138,"avatar_url":"https://avatars.githubusercontent.com/u/14679138?v=3","gravatar_id":"","url":"https://api.github.com/users/sf-wdi-22-23","html_url":"https://github.com/sf-wdi-22-23","followers_url":"https://api.github.com/users/sf-wdi-22-23/followers","following_url":"https://api.github.com/users/sf-wdi-22-23/following{/other_user}","gists_url":"https://api.github.com/users/sf-wdi-22-23/gists{/gist_id}","starred_url":"https://api.github.com/users/sf-wdi-22-23/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sf-wdi-22-23/subscriptions","organizations_url":"https://api.github.com/users/sf-wdi-22-23/orgs","repos_url":"https://api.github.com/users/sf-wdi-22-23/repos","events_url":"https://api.github.com/users/sf-wdi-22-23/events{/privacy}","received_events_url":"https://api.github.com/users/sf-wdi-22-23/received_events","type":"Organization","site_admin":false},"repo":{"id":42953458,"name":"modules-23","full_name":"sf-wdi-22-23/modules-23","owner":{"login":"sf-wdi-22-23","id":14679138,"avatar_url":"https://avatars.githubusercontent.com/u/14679138?v=3","gravatar_id":"","url":"https://api.github.com/users/sf-wdi-22-23","html_url":"https://github.com/sf-wdi-22-23","followers_url":"https://api.github.com/users/sf-wdi-22-23/followers","following_url":"https://api.github.com/users/sf-wdi-22-23/following{/other_user}","gists_url":"https://api.github.com/users/sf-wdi-22-23/gists{/gist_id}","starred_url":"https://api.github.com/users/sf-wdi-22-23/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sf-wdi-22-23/subscriptions","organizations_url":"https://api.github.com/users/sf-wdi-22-23/orgs","repos_url":"https://api.github.com/users/sf-wdi-22-23/repos","events_url":"https://api.github.com/users/sf-wdi-22-23/events{/privacy}","received_events_url":"https://api.github.com/users/sf-wdi-22-23/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sf-wdi-22-23/modules-23","description":"Lesson notes, exercises, and solutions","fork":false,"url":"https://api.github.com/repos/sf-wdi-22-23/modules-23","forks_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/forks","keys_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/teams","hooks_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/hooks","issue_events_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/issues/events{/number}","events_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/events","assignees_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/assignees{/user}","branches_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/branches{/branch}","tags_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/tags","blobs_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/git/refs{/sha}","trees_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/statuses/{sha}","languages_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/languages","stargazers_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/stargazers","contributors_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/contributors","subscribers_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/subscribers","subscription_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/subscription","commits_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/commits{/sha}","git_commits_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/git/commits{/sha}","comments_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/comments{/number}","issue_comment_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/issues/comments{/number}","contents_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/contents/{+path}","compare_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/merges","archive_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/downloads","issues_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/issues{/number}","pulls_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/pulls{/number}","milestones_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/milestones{/number}","notifications_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/labels{/name}","releases_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/releases{/id}","created_at":"2015-09-22T18:40:35Z","updated_at":"2015-10-30T06:44:52Z","pushed_at":"2015-11-04T03:05:54Z","git_url":"git://github.com/sf-wdi-22-23/modules-23.git","ssh_url":"git@github.com:sf-wdi-22-23/modules-23.git","clone_url":"https://github.com/sf-wdi-22-23/modules-23.git","svn_url":"https://github.com/sf-wdi-22-23/modules-23","homepage":null,"size":8640,"stargazers_count":8,"watchers_count":8,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":39,"mirror_url":null,"open_issues_count":3,"forks":39,"open_issues":3,"watchers":8,"default_branch":"master"}},"base":{"label":"sf-wdi-22-23:master","ref":"master","sha":"9c15f1ffc0506f89a644c6d792056c007f0c90ac","user":{"login":"sf-wdi-22-23","id":14679138,"avatar_url":"https://avatars.githubusercontent.com/u/14679138?v=3","gravatar_id":"","url":"https://api.github.com/users/sf-wdi-22-23","html_url":"https://github.com/sf-wdi-22-23","followers_url":"https://api.github.com/users/sf-wdi-22-23/followers","following_url":"https://api.github.com/users/sf-wdi-22-23/following{/other_user}","gists_url":"https://api.github.com/users/sf-wdi-22-23/gists{/gist_id}","starred_url":"https://api.github.com/users/sf-wdi-22-23/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sf-wdi-22-23/subscriptions","organizations_url":"https://api.github.com/users/sf-wdi-22-23/orgs","repos_url":"https://api.github.com/users/sf-wdi-22-23/repos","events_url":"https://api.github.com/users/sf-wdi-22-23/events{/privacy}","received_events_url":"https://api.github.com/users/sf-wdi-22-23/received_events","type":"Organization","site_admin":false},"repo":{"id":42953458,"name":"modules-23","full_name":"sf-wdi-22-23/modules-23","owner":{"login":"sf-wdi-22-23","id":14679138,"avatar_url":"https://avatars.githubusercontent.com/u/14679138?v=3","gravatar_id":"","url":"https://api.github.com/users/sf-wdi-22-23","html_url":"https://github.com/sf-wdi-22-23","followers_url":"https://api.github.com/users/sf-wdi-22-23/followers","following_url":"https://api.github.com/users/sf-wdi-22-23/following{/other_user}","gists_url":"https://api.github.com/users/sf-wdi-22-23/gists{/gist_id}","starred_url":"https://api.github.com/users/sf-wdi-22-23/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sf-wdi-22-23/subscriptions","organizations_url":"https://api.github.com/users/sf-wdi-22-23/orgs","repos_url":"https://api.github.com/users/sf-wdi-22-23/repos","events_url":"https://api.github.com/users/sf-wdi-22-23/events{/privacy}","received_events_url":"https://api.github.com/users/sf-wdi-22-23/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sf-wdi-22-23/modules-23","description":"Lesson notes, exercises, and solutions","fork":false,"url":"https://api.github.com/repos/sf-wdi-22-23/modules-23","forks_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/forks","keys_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/teams","hooks_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/hooks","issue_events_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/issues/events{/number}","events_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/events","assignees_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/assignees{/user}","branches_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/branches{/branch}","tags_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/tags","blobs_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/git/refs{/sha}","trees_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/statuses/{sha}","languages_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/languages","stargazers_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/stargazers","contributors_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/contributors","subscribers_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/subscribers","subscription_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/subscription","commits_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/commits{/sha}","git_commits_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/git/commits{/sha}","comments_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/comments{/number}","issue_comment_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/issues/comments{/number}","contents_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/contents/{+path}","compare_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/merges","archive_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/downloads","issues_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/issues{/number}","pulls_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/pulls{/number}","milestones_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/milestones{/number}","notifications_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/labels{/name}","releases_url":"https://api.github.com/repos/sf-wdi-22-23/modules-23/releases{/id}","created_at":"2015-09-22T18:40:35Z","updated_at":"2015-10-30T06:44:52Z","pushed_at":"2015-11-04T03:05:54Z","git_url":"git://github.com/sf-wdi-22-23/modules-23.git","ssh_url":"git@github.com:sf-wdi-22-23/modules-23.git","clone_url":"https://github.com/sf-wdi-22-23/modules-23.git","svn_url":"https://github.com/sf-wdi-22-23/modules-23","homepage":null,"size":8640,"stargazers_count":8,"watchers_count":8,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":39,"mirror_url":null,"open_issues_count":3,"forks":39,"open_issues":3,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sf-wdi-22-23/modules-23/pulls/74"},"html":{"href":"https://github.com/sf-wdi-22-23/modules-23/pull/74"},"issue":{"href":"https://api.github.com/repos/sf-wdi-22-23/modules-23/issues/74"},"comments":{"href":"https://api.github.com/repos/sf-wdi-22-23/modules-23/issues/74/comments"},"review_comments":{"href":"https://api.github.com/repos/sf-wdi-22-23/modules-23/pulls/74/comments"},"review_comment":{"href":"https://api.github.com/repos/sf-wdi-22-23/modules-23/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sf-wdi-22-23/modules-23/pulls/74/commits"},"statuses":{"href":"https://api.github.com/repos/sf-wdi-22-23/modules-23/statuses/f26b690a546b3d09b461b541034086181fa5d5b3"}}}}