Module: Microdata
- Defined in:
- lib/microdata.rb,
lib/microdata/item.rb,
lib/microdata/version.rb,
lib/microdata/document.rb,
lib/microdata/itemprop.rb
Defined Under Namespace
Classes: Document, Item, Itemprop
Constant Summary collapse
- VERSION =
"0.0.3"
Class Method Summary collapse
-
.get_items(location) ⇒ Object
PROPERTY_VALUES = { meta: ‘content’, audio: ‘src’, embed: ‘src’, iframe: ‘src’, img: ‘src’, source: ‘src’, video: ‘src’, a: ‘href’, area: ‘href’, link: ‘href’, object: ‘data’, time: ‘datetime’ }.
- .to_json(location) ⇒ Object
Class Method Details
.get_items(location) ⇒ Object
PROPERTY_VALUES =
meta: 'content',
audio: 'src',
embed: 'src',
iframe: 'src',
img: 'src',
source: 'src',
video: 'src',
a: 'href',
area: 'href',
link: 'href',
object: 'data',
time: 'datetime'
27 28 29 30 31 |
# File 'lib/microdata.rb', line 27 def self.get_items(location) content = open(location) page_url = location Microdata::Document.new(content, page_url).extract_items end |
.to_json(location) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/microdata.rb', line 33 def self.to_json(location) items = get_items(location) hash = {} hash[:items] = items.map do |item| item.to_hash end JSON.pretty_generate hash end |