-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path8.rb
More file actions
35 lines (28 loc) · 686 Bytes
/
8.rb
File metadata and controls
35 lines (28 loc) · 686 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#encoding: utf-8
require_relative '8c'
module Blog
class Post
# include Tweetable
attr_reader :author, :title, :body, :comments
def initialize options
@author = options[:author]
@title = options[:title]
@body = options[:body]
@comments = options[:comments] || []
end
def insert_comment *comments #splat! muchas cosas se pueden hacer con esto
comments.each { |c| @comments << c }
end
def insert_random_comment
@comments << Comment.new(user: 'Me', body: 'A random comment')
end
end
class Comment
include Tweetable
attr_reader :user, :body
def initialize options
@user = options[:user]
@body = options[:body]
end
end
end