Class: Seorel::Helper::Twitter

Inherits:
Base
  • Object
show all
Defined in:
lib/seorel/helper/twitter.rb

Instance Attribute Summary

Attributes inherited from Base

#params, #request

Instance Method Summary collapse

Methods inherited from Base

#helpers, #image_url, #initialize, #locale, #render

Constructor Details

This class inherits a constructor from Seorel::Helper::Base

Instance Method Details

#allObject



29
30
31
32
33
34
35
36
# File 'lib/seorel/helper/twitter.rb', line 29

def all
  ([
    title_tag,
    description_tag,
    image_tag,
    url_tag
  ] + custom_tags).compact
end

#custom_tagsObject



23
24
25
26
27
# File 'lib/seorel/helper/twitter.rb', line 23

def custom_tags
  params.twitter_extras.reduce([]) do |data, (key, value)|
    data.push custum_tag(key, value)
  end
end

#description_tagObject



11
12
13
# File 'lib/seorel/helper/twitter.rb', line 11

def description_tag
  h. :meta, nil, name: 'twitter:description', content: description
end

#image_tagObject



15
16
17
# File 'lib/seorel/helper/twitter.rb', line 15

def image_tag
  h.(:meta, nil, name: 'twitter:image', content: image_url) if image
end

#title_tagObject



7
8
9
# File 'lib/seorel/helper/twitter.rb', line 7

def title_tag
  h. :meta, nil, name: 'twitter:title', content: title
end

#url_tagObject



19
20
21
# File 'lib/seorel/helper/twitter.rb', line 19

def url_tag
  h.(:meta, nil, name: 'twitter:url', content: request.url)
end