Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 6096967cb1
Fetching contributors…

Cannot retrieve contributors at this time

47 lines (35 sloc) 0.769 kb
module HN2JSON
class Entity
attr_accessor :type, :id, :parent, :url, :title, :comments, :votes
attr_accessor :fulltext, :posted_by, :date_posted, :voting_on
def initialize id
@id = id
@type = nil
@parent = nil
@url = nil
@title = nil
@fulltext = nil
@posted_by = nil
@date_posted = nil
@voting_on = nil
@comments = nil
@votes = nil
get_page
determine_type
get_attrs
end
def get_page
@html = Request.new(id)
@parser = Parser.new @html
end
def determine_type
@type = @parser.determine_type
end
def get_attrs
eval("@parser.get_attrs_#{@type.to_s} self")
end
def add_attrs
yield self
end
end
end
Jump to Line
Something went wrong with that request. Please try again.