Class: Reddit::Post

Inherits:
Object
  • Object
show all
Defined in:
lib/reddit/post.rb

Constant Summary collapse

@@post =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, author, timestamp, comments, upvotes, url) ⇒ Post

Returns a new instance of Post.



6
7
8
9
10
11
12
13
14
15
# File 'lib/reddit/post.rb', line 6

def initialize(title, author, timestamp, comments, upvotes, url)
  @title = title
  @author = author
  @timestamp = timestamp
  @comments = comments
  @upvotes = upvotes
  @url = url

  @@post << self
end

Instance Attribute Details

#authorObject

Returns the value of attribute author.



2
3
4
# File 'lib/reddit/post.rb', line 2

def author
  @author
end

#commentsObject

Returns the value of attribute comments.



2
3
4
# File 'lib/reddit/post.rb', line 2

def comments
  @comments
end

#timestampObject

Returns the value of attribute timestamp.



2
3
4
# File 'lib/reddit/post.rb', line 2

def timestamp
  @timestamp
end

#titleObject

Returns the value of attribute title.



2
3
4
# File 'lib/reddit/post.rb', line 2

def title
  @title
end

#upvotesObject

Returns the value of attribute upvotes.



2
3
4
# File 'lib/reddit/post.rb', line 2

def upvotes
  @upvotes
end

#urlObject

Returns the value of attribute url.



2
3
4
# File 'lib/reddit/post.rb', line 2

def url
  @url
end

Class Method Details

.allObject



17
18
19
# File 'lib/reddit/post.rb', line 17

def self.all
  @@post
end