Sha256: 19aab7b0f2dae2ec0ebfb13b6d0efadab5d68c0a13c2b04b9b4ffde955e19b92

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

module Writer
  module Fetcher
    module Microdata
      class UserComments
        attr_accessor :source

        def initialize the_source
          self.source = the_source
        end

        def hash
          @attributes = @source.attributes
          aux = @attributes[:id].split("_")
          url = "https://www.facebook.com/#{aux[1]}?comment_id=#{aux[2]}"
          resp = {
            "type" => [@source._type],
            "properties" => {
              "additionalType" => [
                @attributes[:additionalType]
              ],
              "Item#id" => [
                "#{@attributes[:id]}"
              ],
              "commentText" => [
                @attributes[:commentText]
              ],
              "creator" => [
                @attributes[:creator].to.hash
              ],
              "commentTime" => [
                @attributes[:commentTime]
              ],
              "url" => [
                url
              ]
            }
          }

          resp["properties"].keys.each do |att|
            if resp["properties"]["#{att}"] == [nil]
              resp["properties"].delete "#{att}"
            end
          end
          resp
          
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fetcher-microdata-0.0.13 lib/writer/fetcher-microdata/user_comments.rb