Class: Hypermicrodata::Extract
- Inherits:
-
Object
- Object
- Hypermicrodata::Extract
- Defined in:
- lib/hypermicrodata/extract.rb
Instance Method Summary collapse
-
#initialize(html, options = {}) ⇒ Extract
constructor
A new instance of Extract.
- #to_json(format = :plain, options = {}) ⇒ Object
Constructor Details
#initialize(html, options = {}) ⇒ Extract
Returns a new instance of Extract.
3 4 5 6 7 8 9 |
# File 'lib/hypermicrodata/extract.rb', line 3 def initialize(html, = {}) default_data_attr_name = 'main-item' @location = [:location] @profile_path = [:profile_path] filter_xpath_attr = "@data-#{[:data_attr_name] || default_data_attr_name}" @document = Hypermicrodata::Document.new(html, page_url: @location, filter_xpath_attr: filter_xpath_attr) end |
Instance Method Details
#to_json(format = :plain, options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/hypermicrodata/extract.rb', line 11 def to_json(format = :plain, = {}) case format when :hal Hypermicrodata::Serializer::Hal.new(@document, @location, @profile_path).to_json() when :uber Hypermicrodata::Serializer::Uber.new(@document, @location, @profile_path).to_json() else Hypermicrodata::Serializer::Base.new(@document, @location, @profile_path).to_json() end end |