Class: OpenGraphReader::Builder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/open_graph_reader/builder.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.

Convert a Parser::Graph into the right hierarchy of Objects attached to a Base, then validate it.

Constant Summary collapse

KNOWN_TYPES =

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.

Well-known types from

See Also:

%w(website article book profile).freeze

Instance Method Summary collapse

Constructor Details

#initialize(parser) ⇒ Builder

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 builder.

Parameters:

See Also:



17
18
19
# File 'lib/open_graph_reader/builder.rb', line 17

def initialize parser
  @parser = parser
end

Instance Method Details

#baseBase

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 base.

Returns:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/open_graph_reader/builder.rb', line 24

def base
  base = Base.new

  type = @parser.graph.fetch("og:type", "website").downcase

  validate_type type

  @parser.graph.each do |property|
    build_property base, property
  end

  synthesize_required_properties base
  drop_empty_children base
  validate base

  base
end