Class: Writer::Fetcher::Microdata::Review

Inherits:
Object
  • Object
show all
Defined in:
lib/writer/fetcher-microdata/review.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(the_source) ⇒ Review

Returns a new instance of Review.



7
8
9
# File 'lib/writer/fetcher-microdata/review.rb', line 7

def initialize the_source
  self.source = the_source
end

Instance Attribute Details

#sourceObject

Returns the value of attribute source.



5
6
7
# File 'lib/writer/fetcher-microdata/review.rb', line 5

def source
  @source
end

Instance Method Details

#hashObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/writer/fetcher-microdata/review.rb', line 11

def hash
  @attributes = @source.attributes
  {
    "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
      ]
    }
  }
end