Sha256: 32cd43293538dc8ac64ccea662ff925f5d2227595a3a4c43c457256a575a58b4

Contents?: true

Size: 607 Bytes

Versions: 1

Compression:

Stored size: 607 Bytes

Contents

module Hckr
  class Document
    DEFAULT_URL = "https://news.ycombinator.com"
    NEWEST_URL  = "#{DEFAULT_URL}/newest"
    BEST_URL    = "#{DEFAULT_URL}/best"
    SHOW_URL    = "#{DEFAULT_URL}/show"
    JOBS_URL    = "#{DEFAULT_URL}/jobs"

    def self.fetch!(arg)
      case arg[:page]
      when :newest 
        Nokogiri::HTML(open(NEWEST_URL)) 
      when :best
        Nokogiri::HTML(open(BEST_URL)) 
      when :show
        Nokogiri::HTML(open(SHOW_URL)) 
      when :jobs
        Nokogiri::HTML(open(JOBS_URL)) 
      else
        Nokogiri::HTML(open(DEFAULT_URL)) 
      end
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hckr-0.0.1 lib/hckr/document.rb