Class: MetaHari::Helpers::Microdata
- Inherits:
-
Object
- Object
- MetaHari::Helpers::Microdata
- Defined in:
- lib/meta_hari/helpers/microdata.rb
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #data(type = 'http://schema.org/Product') ⇒ Object
-
#initialize(document, url) ⇒ Microdata
constructor
A new instance of Microdata.
Constructor Details
#initialize(document, url) ⇒ Microdata
Returns a new instance of Microdata.
7 8 9 10 |
# File 'lib/meta_hari/helpers/microdata.rb', line 7 def initialize(document, url) @document = document @url = url end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
4 5 6 |
# File 'lib/meta_hari/helpers/microdata.rb', line 4 def document @document end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/meta_hari/helpers/microdata.rb', line 5 def url @url end |
Instance Method Details
#data(type = 'http://schema.org/Product') ⇒ Object
12 13 14 15 |
# File 'lib/meta_hari/helpers/microdata.rb', line 12 def data(type = 'http://schema.org/Product') result = array.find { |hash| hash[:type].include? type } result && format(result) || {} end |