Last active
August 29, 2015 13:58
-
-
Save bswinnerton/10429797 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require_relative 'lib/user' | |
| require_relative 'lib/post' | |
| #require 'pry' | |
| brooks = User.new('Brooks', 'brooks@ga.co') | |
| Post.new('Cat takes over the world', 'asdfasdfas', brooks) | |
| Post.new('colbert', 'asdf', brooks) | |
| Post.new('asdf', 'qwer', brooks) | |
| Post.all.each do |post| | |
| puts post | |
| puts | |
| end | |
| #binding.pry |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Post | |
| attr_accessor :title, :body, :author | |
| @@posts = [] | |
| def initialize(title, body, author) | |
| @title = title | |
| @body = body | |
| @author = author | |
| @@posts << self | |
| end | |
| def self.all | |
| @@posts | |
| end | |
| def to_s | |
| "Title: #{@title}\nBody: #{@body}" | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class User | |
| attr_accessor :name, :email | |
| def initialize(name, email) | |
| @name = name | |
| @email = email | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment