Class: OpenGraph::Object
- Inherits:
-
Hashie::Mash
- Object
- Hashie::Mash
- OpenGraph::Object
- Defined in:
- lib/urifetch/ext/opengraph.rb
Overview
The OpenGraph::Object is a Hash with method accessors for all detected Open Graph attributes.
Constant Summary collapse
- MANDATORY_ATTRIBUTES =
%w(title type image url)
Instance Method Summary collapse
-
#schema ⇒ Object
The schema under which this particular object lies.
-
#type ⇒ Object
The object type.
-
#valid? ⇒ Boolean
If the Open Graph information for this object doesn’t contain the mandatory attributes, this will be
false
.
Instance Method Details
#schema ⇒ Object
The schema under which this particular object lies. May be any of the keys of the TYPES constant.
44 45 46 47 48 49 |
# File 'lib/urifetch/ext/opengraph.rb', line 44 def schema OpenGraph::TYPES.each_pair do |schema, types| return schema if types.include?(self.type) end nil end |
#type ⇒ Object
The object type.
38 39 40 |
# File 'lib/urifetch/ext/opengraph.rb', line 38 def type self['type'] end |
#valid? ⇒ Boolean
If the Open Graph information for this object doesn’t contain the mandatory attributes, this will be false
.
65 66 67 68 |
# File 'lib/urifetch/ext/opengraph.rb', line 65 def valid? MANDATORY_ATTRIBUTES.each{|a| return false unless self[a]} true end |