Method: OpenGraphReader::Parser::Graph#fetch

Defined in:
lib/open_graph_reader/parser/graph.rb

#fetch(property, default = nil) { ... } ⇒ 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.

Fetch first node’s value.

Parameters:

  • property (String)

    The fully qualified name, for example og:type.

  • default (String) (defaults to: nil)

    The default in case the a value is not found.

Yields:

  • Return a default in case the value is not found. Supersedes the default parameter.

Returns:

  • (String, Bool, Integer, Float, DateTime, nil)


124
125
126
127
128
129
# File 'lib/open_graph_reader/parser/graph.rb', line 124

def fetch property, default = nil
  node = find_by(property)
  return yield if node.nil? && block_given?
  return default if node.nil?
  node.content
end