Class: OpenGraphReader::Base
- Inherits:
-
Object
- Object
- OpenGraphReader::Base
- 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
-
#bases ⇒ String => Object
(also: #children)
readonly
private
Return the stored root objects as a hash.
-
#origin ⇒ String?
If available, contains the source location of the document the available objects were parsed from.
Instance Method Summary collapse
-
#[](name) ⇒ Object?
private
Get a root object by name.
-
#[]=(name, object) ⇒ Object
private
Make a new root object available on this base.
-
#initialize ⇒ Base
constructor
private
A new instance of Base.
-
#method_missing(method, *args, &block) ⇒ Object
Makes the found root objects available.
Constructor Details
#initialize ⇒ Base
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.
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
#bases ⇒ String => 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.
46 47 48 |
# File 'lib/open_graph_reader/base.rb', line 46 def bases @bases end |
#origin ⇒ String?
If available, contains the source location of the document the available objects were parsed from.
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.
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.
27 |
# File 'lib/open_graph_reader/base.rb', line 27 def_delegators :@bases, :[], :[]=, :each_value |