Sha256: 867877a9b4d441a5700ba7f5c75ebc2ab2c63d79f8c82ce434585cda24fa7cb2

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

module Writer
  module Fetcher
    module Microdata
      class ArticleSmall
        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]
              ],
              "articleBody" => [
                @attributes[:articleBody]
              ],
              "author" => [
                @attributes[:author].to.hash
              ],
              "Item#viewer" => [
                @attributes[:viewer].to.hash
              ],
              "UserComments" => [
              ],
              "dateCreated" => [
                @attributes[:dateCreated]
              ],
              "provider" => @attributes[:provider],
              "url" => [
                @attributes[:url]
              ]
            }
          }
          @attributes[:comments].each do |c|
            resp["properties"]["UserComments"].push c.to.hash
          end
          resp
          
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fetcher-microdata-0.0.12 lib/writer/fetcher-microdata/article_small.rb
fetcher-microdata-0.0.11 lib/writer/fetcher-microdata/article_small.rb