class TwitterCards::Object

The TwitterCards::Object is a Hash with method accessors for all detected Twitter Cards attributes.

Constants

MANDATORY_ATTRIBUTES

Public Instance Methods

image() click to toggle source

Quick way to fetch image

# File lib/twitter_cards.rb, line 82
def image
  self['image'] || self['image_src']
end
image?() click to toggle source

Check if image property exists

# File lib/twitter_cards.rb, line 87
def image?
  image ? true : false
end
type() click to toggle source

The object type, summary if no card property found.

# File lib/twitter_cards.rb, line 77
def type
  self['card'] || 'summary'
end
valid?() click to toggle source

If the Twitter Cards information for this object doesn't contain the mandatory attributes, this will be false.

# File lib/twitter_cards.rb, line 100
def valid?
  MANDATORY_ATTRIBUTES[type].each{|a| return false unless self[a]}
  true
end