Class: Embedify::Object

Inherits:
Hashie::Mash
  • Object
show all
Defined in:
lib/embedify.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.



170
171
172
173
174
175
# File 'lib/embedify.rb', line 170

def schema
  Embedify::TYPES.each_pair do |schema, types|
    return schema if types.include?(self.type)
  end
  nil
end

#typeObject

The object type.



164
165
166
# File 'lib/embedify.rb', line 164

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)


191
192
193
194
# File 'lib/embedify.rb', line 191

def valid?
  MANDATORY_ATTRIBUTES.each{|a| return false unless (self[a] && !self[a].empty?)}
  true
end