Class: OpenGraphReader::Parser Private
- Inherits:
-
Object
- Object
- OpenGraphReader::Parser
- Defined in:
- lib/open_graph_reader/parser.rb,
lib/open_graph_reader/parser/graph.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Parse OpenGraph tags in a HTML document into a graph.
Defined Under Namespace
Classes: Graph
Constant Summary collapse
- XPathHelpers =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Some helper methods for Nokogiri
Class.new do # Helper to lowercase all given properties def ci_starts_with node_set, string node_set.select {|node| node.to_s.downcase.start_with? string.downcase } end end.new
Instance Attribute Summary collapse
-
#additional_namespaces ⇒ Array<String>
readonly
private
Namespaces found in the passed documents head tag.
Instance Method Summary collapse
-
#graph ⇒ Graph
private
Build and return the Graph.
-
#has_tags? ⇒ Bool
private
Whether there are any OpenGraph tags at all.
-
#initialize(html, origin = nil) ⇒ Parser
constructor
private
Create a new parser.
-
#title ⇒ String
private
The value of the title tag of the passed document.
Constructor Details
#initialize(html, origin = nil) ⇒ Parser
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a new parser.
29 30 31 32 33 |
# File 'lib/open_graph_reader/parser.rb', line 29 def initialize html, origin=nil @doc = to_doc html @origin = origin @additional_namespaces = [] end |
Instance Attribute Details
#additional_namespaces ⇒ Array<String> (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Namespaces found in the passed documents head tag
23 24 25 |
# File 'lib/open_graph_reader/parser.rb', line 23 def additional_namespaces @additional_namespaces end |
Instance Method Details
#graph ⇒ Graph
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build and return the Graph.
45 46 47 |
# File 'lib/open_graph_reader/parser.rb', line 45 def graph @graph ||= build_graph end |
#has_tags? ⇒ Bool
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Whether there are any OpenGraph tags at all.
38 39 40 |
# File 'lib/open_graph_reader/parser.rb', line 38 def !graph.empty? end |
#title ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The value of the title tag of the passed document.
52 53 54 |
# File 'lib/open_graph_reader/parser.rb', line 52 def title @doc.xpath('/html/head/title').first.text end |