Class: SemanticCrawler::Websites::MicroData
- Inherits:
-
Object
- Object
- SemanticCrawler::Websites::MicroData
- Defined in:
- lib/semantic_crawler/websites/micro_data.rb
Overview
Extract microdata from a website and output it as JSON
Instance Attribute Summary collapse
-
#microdata ⇒ Object
Returns the value of attribute microdata.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url) ⇒ MicroData
constructor
A new instance of MicroData.
- #to_json ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(url) ⇒ MicroData
Returns a new instance of MicroData.
12 13 14 15 16 17 |
# File 'lib/semantic_crawler/websites/micro_data.rb', line 12 def initialize(url) doc = Nokogiri::HTML(open(url)) microdata = Microdata::Document.new(doc.to_s) items = microdata.extract_items self.microdata = extract_microdata(items) end |
Instance Attribute Details
#microdata ⇒ Object
Returns the value of attribute microdata.
10 11 12 |
# File 'lib/semantic_crawler/websites/micro_data.rb', line 10 def microdata @microdata end |
#url ⇒ Object
Returns the value of attribute url.
9 10 11 |
# File 'lib/semantic_crawler/websites/micro_data.rb', line 9 def url @url end |
Instance Method Details
#to_json ⇒ Object
19 20 21 |
# File 'lib/semantic_crawler/websites/micro_data.rb', line 19 def to_json microdata.to_json end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/semantic_crawler/websites/micro_data.rb', line 23 def to_s microdata end |