Class: Writer::Fetcher::Microdata::Review
- Inherits:
-
Object
- Object
- Writer::Fetcher::Microdata::Review
- Defined in:
- lib/writer/fetcher-microdata/review.rb
Instance Attribute Summary collapse
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #hash ⇒ Object
-
#initialize(the_source) ⇒ Review
constructor
A new instance of Review.
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
#source ⇒ Object
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
#hash ⇒ Object
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 44 45 46 47 48 49 50 51 |
# File 'lib/writer/fetcher-microdata/review.rb', line 11 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 |