Sha256: b6ddbccae1135d14e9598c7b9231b49eaa506873ad373591424dbaf72947bb25

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

module Writer
  module Fetcher
    module Microdata
      class Review
        attr_accessor :source

        def initialize the_source
          self.source = the_source
        end

        def hash
          @attributes = @source.attributes
          resp = {
            "type" => [@source._type],
            "properties" => {
              "additionalType" => [
                @attributes[:additionalType]
              ],
              "Item#id" => [
                @attributes[:id]
              ],
              "reviewBody" => [
                @attributes[:reviewBody]
              ],
              "author" => [
                @attributes[:author].to.hash
              ],
              "Item#viewer" => [
                @attributes[:viewer].to.hash
              ],
              "dateCreated" => [
                @attributes[:dateCreated]
              ],
              "provider" => @attributes[:provider],
              "url" => [
                @attributes[:url]
              ],
              "itemReviewed" => [
                @attributes[:itemReviewed].to.hash
              ]
            }
          }

          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/review.rb