Class: HNPosts::Post

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Post

Returns a new instance of Post.



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

def initialize( options )
  @post_id = options[:post_id]
  @title = options[:title]
  @url = options[:url]
  @points = options[:points]
  @comments = options[:comments]
  @position = options[:position]
end

Instance Attribute Details

#commentsObject (readonly)

Returns the value of attribute comments.



5
6
7
# File 'lib/hnposts/post.rb', line 5

def comments
  @comments
end

#pointsObject (readonly)

Returns the value of attribute points.



5
6
7
# File 'lib/hnposts/post.rb', line 5

def points
  @points
end

#positionObject (readonly)

Returns the value of attribute position.



5
6
7
# File 'lib/hnposts/post.rb', line 5

def position
  @position
end

#post_idObject (readonly)

Returns the value of attribute post_id.



5
6
7
# File 'lib/hnposts/post.rb', line 5

def post_id
  @post_id
end

#titleObject (readonly)

Returns the value of attribute title.



5
6
7
# File 'lib/hnposts/post.rb', line 5

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



5
6
7
# File 'lib/hnposts/post.rb', line 5

def url
  @url
end

Instance Method Details

#to_sObject



16
17
18
# File 'lib/hnposts/post.rb', line 16

def to_s
  "#{post_id} - position #{position}, #{title}, #{points} points #{comments} comments, #{url}"
end