hn2json 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/lib/hn2json.rb CHANGED
@@ -27,12 +27,12 @@ module HN2JSON
27
27
  # Public: Make a request to HackerNews and extract retrieved data.
28
28
  #
29
29
  # id - The ID of the page to request
30
- #
30
+ # preserve_html - If true the html and parser won't be remove form the object (default: false)
31
31
  #
32
32
  # Returns the fetched HackerNews Entity.
33
- def find id
33
+ def find id, preserve_html=false
34
34
  check_for_falsy_id id
35
- Entity.new id
35
+ Entity.new id, preserve_html
36
36
  end
37
37
 
38
38
  private
@@ -36,7 +36,7 @@ module HN2JSON
36
36
  attr_accessor :voting_on
37
37
 
38
38
 
39
- def initialize id
39
+ def initialize id, preserve_html=false
40
40
  @id = id
41
41
 
42
42
  @type = nil
@@ -54,6 +54,9 @@ module HN2JSON
54
54
  determine_type
55
55
 
56
56
  get_attrs
57
+
58
+ remove_instance_variable :@html unless preserve_html
59
+ remove_instance_variable :@parser unless preserve_html
57
60
  end
58
61
 
59
62
  def get_page
@@ -1,4 +1,4 @@
1
1
  module HN2JSON
2
2
  # Public: String current version of HN2JSON
3
- VERSION = '0.0.6'
3
+ VERSION = '0.0.7'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hn2json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: