Skip to content
This repository has been archived by the owner on Dec 22, 2021. It is now read-only.

Commit

Permalink
Added further [doc] of the attr_readers of HN Entities.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcla1 committed Oct 7, 2012
1 parent 3b8f4d0 commit be4d2c1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
37 changes: 34 additions & 3 deletions lib/hn2json/entity.rb
@@ -1,9 +1,40 @@
module HN2JSON

# Internal: Represents a post, poll, discussion or comment on HackerNews.
class Entity

attr_accessor :type, :id, :parent, :url, :title, :comments, :votes
attr_accessor :fulltext, :posted_by, :date_posted, :voting_on
# Public: Returns the IDs of all top-level comments.
attr_reader :comments

# Public: Returns the String date when the Entity was posted to HackerNews.
attr_reader :date_posted

# Public: Return the String text of the Entity, if available.
attr_reader :fulltext

# Public: Returns the Integer ID of the Entity
attr_reader :id

# Public: Returns the Integer ID of the parent, if available
attr_reader :parent

# Public: Returns the String username of the user who posted the Entity
attr_reader :posted_by

# Public: Returns the String title of the Entity, if available
attr_reader :title

# Public: Returns the Symbol type of the Entity (:post, :poll, :discussion, :comment)
attr_reader :type

# Public: Returns the String url of an Entity, if available
attr_reader :url

# Public: Returns the Interger number of upvotes the Entity has recieved
attr_reader :votes

# Public: Returns a 2D Array of ["Thing you're voting on", number of upvotes]
attr_reader :voting_on


def initialize id
@id = id
Expand Down
1 change: 1 addition & 0 deletions lib/hn2json/version.rb
@@ -1,3 +1,4 @@
module HN2JSON
# Public: String current version of HN2JSON
VERSION = '0.0.4'
end

0 comments on commit be4d2c1

Please sign in to comment.