Sha256: dce51b42cae96cfc01fc0bb9fcc3afbe44f69d00b9ed89dd5f96b823b49747a0

Contents?: true

Size: 489 Bytes

Versions: 2

Compression:

Stored size: 489 Bytes

Contents

module HackernewsApi
  class Story
    def self.fetch id
      json = Client.fetch(:item, id)
      new(json)
    end

    attr_reader :id, :by, :kids, :score, :time, :title, :type, :url

    def initialize json
      @id     = json['id']
      @by     = json['by']
      @kids   = json['kids']
      @score  = json['score']
      @time   = DateTime.strptime(json['time'].to_s, '%s')
      @title  = json['title']
      @type   = json['type']
      @url    = json['url']
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hackernews_api-0.0.2 lib/hackernews_api/story.rb
hackernews_api-0.0.1 lib/hackernews_api/story.rb