Class: OpenGraph::Object

Inherits:
Hashie::Mash
  • Object
show all
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

Instance Method Details

#schemaObject

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

#typeObject

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.

Returns:

  • (Boolean)


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