Sha256: ab1d0359a333cb3557be477597131003cfd338186b652577f24810d5b603eb9c

Contents?: true

Size: 716 Bytes

Versions: 1

Compression:

Stored size: 716 Bytes

Contents

class IGScrape::Comment

  attr_accessor :id, :text, :created_at, :author_id, :author_name, :author_profile_pic

  def initialize(payload)
    load_from_payload(payload)
  end

  def to_json(*args)
    JSON.generate({
      id: @id,
      text: @text,
      created_at: @created_at,
      author_id: @author_id,
      author_name: @author_name,
      author_profile_pic: @author_profile_pic
    })
  end

  private

    def load_from_payload payload
      @id = payload["id"]
      @text = payload["text"]
      @created_at = payload["created_at"]
      @author_id = payload["owner"]["id"]
      @author_profile_pic = payload["owner"]["profile_pic_url"]
      @author_name = payload["owner"]["username"]
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ig_scrape-0.0.3 lib/ig_scrape/comment.rb