Class: OpenGraphReader::Parser Private

Inherits:
Object
  • Object
show all
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.

API:

  • private

Defined Under Namespace

Modules: XPathHelpers Classes: Graph

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(html) ⇒ 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.

Parameters:

  • the document to parse.

API:

  • private



28
29
30
31
# File 'lib/open_graph_reader/parser.rb', line 28

def initialize html
  @doc = to_doc html
  @additional_namespaces = []
end

Instance Attribute Details

#additional_namespacesArray<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

Returns:

API:

  • private



23
24
25
# File 'lib/open_graph_reader/parser.rb', line 23

def additional_namespaces
  @additional_namespaces
end

Instance Method Details

#any_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.

Returns:

API:

  • private



36
37
38
# File 'lib/open_graph_reader/parser.rb', line 36

def any_tags?
  graph.exist?("og")
end

#graphGraph

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.

Returns:

API:

  • private



43
44
45
# File 'lib/open_graph_reader/parser.rb', line 43

def graph
  @graph ||= build_graph
end

#titleString

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.

Returns:

API:

  • private



50
51
52
# File 'lib/open_graph_reader/parser.rb', line 50

def title
  @doc.xpath("/html/head/title").first&.text
end