Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added [doc] to the main require file (hn2json.rb)

  • Loading branch information...
commit 3b8f4d08a6c17f6dded710c241683b754b06cc9f 1 parent db6a48a
@jcla1 authored
Showing with 20 additions and 1 deletion.
  1. +20 −1 lib/hn2json.rb
View
21 lib/hn2json.rb
@@ -2,6 +2,13 @@
require 'nokogiri'
require 'chronic'
+
+# Public: Interface to HackerNews (news.ycombinator.com)
+#
+# Examples
+#
+# HN2JSON.find 123456
+# # => HN2JSON::Entity:0xffffffffffffff
module HN2JSON
extend HN2JSON
@@ -17,7 +24,12 @@ module HN2JSON
autoload :VERSION, 'hn2json/version'
-
+ # Public: Make a request to HackerNews and extract retrieved data.
+ #
+ # id - The ID of the page to request
+ #
+ #
+ # Returns the fetched HackerNews Entity.
def find id
check_for_falsy_id id
Entity.new id
@@ -25,6 +37,13 @@ def find id
private
+ # Internal: Check if a given ID is valid to be requested.
+ #
+ # id - The ID to check.
+ #
+ #
+ # Returns nothing.
+ # Raises HN2JSON::InvalidIdError if the ID is invalid.
def check_for_falsy_id id
if id.class != Fixnum || id < 1
raise InvalidIdError, "id must be > 0 and a Fixnum, you passed #{id}"
Please sign in to comment.
Something went wrong with that request. Please try again.