Class: OpenGraphReader::Base

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/open_graph_reader/base.rb

Overview

You get an instance of this class as result of your quest to obtain an OpenGraph object. It simply contains and returns the root objects, most commonly og.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

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.

Returns a new instance of Base.



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

def initialize
  @bases = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

Makes the found root objects available.

Returns:



61
62
63
64
65
66
67
68
# File 'lib/open_graph_reader/base.rb', line 61

def method_missing(method, *args, &block)
  name = method.to_s
  if respond_to_missing? name
    @bases[name]
  else
    super(method, *args, &block)
  end
end

Instance Attribute Details

#basesString => Object (readonly) Also known as: children

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.

Return the stored root objects as a hash.

Returns:



46
47
48
# File 'lib/open_graph_reader/base.rb', line 46

def bases
  @bases
end

#originString?

If available, contains the source location of the document the available objects were parsed from.

Returns:

  • (String, nil)


34
35
36
# File 'lib/open_graph_reader/base.rb', line 34

def origin
  @origin
end

Instance Method Details

#[](name) ⇒ Object?

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.

Get a root object by name.

Parameters:

  • name (String)

    The name of the root namespace.

Returns:

  • (Object, nil)

    The corresponding root object if available.



27
# File 'lib/open_graph_reader/base.rb', line 27

def_delegators :@bases, :[], :[]=, :each_value

#[]=(name, object) ⇒ Object

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.

Make a new root object available on this base.

Parameters:

  • name (String)

    The name of the root namespace.

  • object (Object)

    The corresponding root object.



27
# File 'lib/open_graph_reader/base.rb', line 27

def_delegators :@bases, :[], :[]=, :each_value