Sha256: 9d3ad234418470e20028fe2436a13739b35eee63b12c8b347d901a285b720ea4

Contents?: true

Size: 455 Bytes

Versions: 2

Compression:

Stored size: 455 Bytes

Contents

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

    attr_reader :id, :by, :kids, :time, :type, :parent, :text

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

Version data entries

2 entries across 2 versions & 1 rubygems

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