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.

Defined Under Namespace

Classes: Graph

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

Parameters:

  • html (#to_s, Nokogiri::XML::Node)

    the document to parse.

  • origin (String) (defaults to: nil)

    The source the document was obtained from.



19
20
21
22
23
# File 'lib/open_graph_reader/parser.rb', line 19

def initialize html, origin=nil
  @doc = to_doc html
  @origin = origin
  @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:

  • (Array<String>)


13
14
15
# File 'lib/open_graph_reader/parser.rb', line 13

def additional_namespaces
  @additional_namespaces
end

Instance Method Details

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



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

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.

Returns:

  • (Bool)


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

def has_tags?
  !graph.empty?
end