Module: Fetcher::Microdata::ArticleSmall::Facebook

Defined in:
lib/fetcher/microdata/article_small/facebook/coercer.rb

Constant Summary collapse

Coercer =
proc { |post, viewer|
  resp = {
    :likes_type => "http://schema.org/AggregateRating/Likes",
    :id => post["post_id"],
    :comments => [],
    :likes => [],
    :articleBody => post["message"],
    :dateCreated => "#{post["created_time"]}",
    :author => PersonUser.new(:facebook, { "id" => "#{post["actor_id"]}" }),
    :likes_count => post["likes"]["count"],
    :comments_count => post["comments"]["count"],
    :viewer         => PersonUser.new(:facebook, { "id" => "#{post["viewer_id"]}" }),
    :provider       => ["facebook"]
  }
  i = 0
  post["likes"]["sample"].each do |like|
    #resp[:likes].push Like.new :facebook, like
    resp[:likes].push "like#{i}"
    i = i + 1
  end
  post["comments"]["comment_list"].each do |comment|
    resp[:comments].push UserComments.new :facebook, comment
  end
  resp
}