Permalink
Browse files

Cut down size of the returned object (remove the [html] and [parser],…

… the biggest vars). The whole of HN should take up about 2-3 GB. Planing on creating a json/xml/rdf dump of HN. Buped version!
  • Loading branch information...
1 parent 8ba312d commit f376b50e1c3996132b8d123a50f03f3367834730 @jcla1 committed Oct 9, 2012
Showing with 8 additions and 5 deletions.
  1. +3 −3 lib/hn2json.rb
  2. +4 −1 lib/hn2json/entity.rb
  3. +1 −1 lib/hn2json/version.rb
View
@@ -27,12 +27,12 @@ module HN2JSON
# Public: Make a request to HackerNews and extract retrieved data.
#
# id - The ID of the page to request
- #
+ # preserve_html - If true the html and parser won't be remove form the object (default: false)
#
# Returns the fetched HackerNews Entity.
- def find id
+ def find id, preserve_html=false
check_for_falsy_id id
- Entity.new id
+ Entity.new id, preserve_html
end
private
View
@@ -36,7 +36,7 @@ class Entity
attr_accessor :voting_on
- def initialize id
+ def initialize id, preserve_html=false
@id = id
@type = nil
@@ -54,6 +54,9 @@ def initialize id
determine_type
get_attrs
+
+ remove_instance_variable :@html unless preserve_html
+ remove_instance_variable :@parser unless preserve_html
end
def get_page
View
@@ -1,4 +1,4 @@
module HN2JSON
# Public: String current version of HN2JSON
- VERSION = '0.0.6'
+ VERSION = '0.0.7'
end

0 comments on commit f376b50

Please sign in to comment.