class Tychus::MetaParser
Attributes
doc[R]
meta[R]
Public Class Methods
new(uri)
click to toggle source
# File lib/tychus/meta_parser.rb, line 19 def initialize(uri) @uri = uri @meta = Meta.new @doc = Nokogiri::HTML(open(uri)) end
Public Instance Methods
parse()
click to toggle source
# File lib/tychus/meta_parser.rb, line 25 def parse set_uri set_open_graph_protocol set_schema_org_microformat meta end
set_open_graph_protocol()
click to toggle source
# File lib/tychus/meta_parser.rb, line 33 def set_open_graph_protocol protocol = doc.css('html').first.attr('xmlns:og') meta.__send__("open_graph_protocol=", protocol) end
set_schema_org_microformat()
click to toggle source
# File lib/tychus/meta_parser.rb, line 39 def set_schema_org_microformat schema_org_property = '[itemtype="http://schema.org/Recipe"]' nodeset = doc.css(schema_org_property) meta.__send__("schema_org_microformat=", nodeset.present?) end
set_uri()
click to toggle source
# File lib/tychus/meta_parser.rb, line 46 def set_uri r = URIResolver.new(@uri, doc) uri_object = r.resolve_uri meta.uri_object = uri_object end