Class: Writer::Fetcher::Microdata::PersonUser
- Inherits:
-
Object
- Object
- Writer::Fetcher::Microdata::PersonUser
- Defined in:
- lib/writer/fetcher-microdata/person_user.rb
Instance Attribute Summary collapse
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #hash ⇒ Object
-
#initialize(the_source) ⇒ PersonUser
constructor
A new instance of PersonUser.
Constructor Details
#initialize(the_source) ⇒ PersonUser
Returns a new instance of PersonUser.
7 8 9 |
# File 'lib/writer/fetcher-microdata/person_user.rb', line 7 def initialize the_source @source = the_source end |
Instance Attribute Details
#source ⇒ Object
Returns the value of attribute source.
5 6 7 |
# File 'lib/writer/fetcher-microdata/person_user.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 |
# File 'lib/writer/fetcher-microdata/person_user.rb', line 11 def hash @attributes = @source.attributes resp = { "type" => [ @source._type ], "properties" => { "additionalType" => [ @attributes[:additionalType] ], "Item#id" => [ @attributes[:id] ], "name" => [ @attributes[:name] ], "User#dateRegistered" => [ @attributes[:dateRegistered] ], "description" => [ @attributes[:description] ], "url" => [ @attributes[:url] ] } } resp["properties"].keys.each do |att| if resp["properties"]["#{att}"] == [nil] resp["properties"].delete "#{att}" end end resp end |