module AdSense::AdFormat

Constants

Button
HalfBanner
LargeLeaderBoard
visit for available formats/sizes

support.google.com/adsense/bin/answer.py?hl=en&answer=185666

LargeRectangle
LargeSkyscraper
LeaderBoard
MediumRectangle
MobileBanner
Skyscraper
SmallRrectangle
SmallSquare
Square
VerticalBanner
WideSkyscraper

Public Class Methods

ad_format_string(format, is_links_ad = false) click to toggle source
# File lib/ad_sense/ad_format.rb, line 29
def ad_format_string(format, is_links_ad = false)
  format_value = get_format_value(format)

  if format_value.present?
    prepend_string = is_links_ad ? '_0ads_al' : '_as'
    "#{format_value}#{prepend_string}"
  end
end
available_formats() click to toggle source
# File lib/ad_sense/ad_format.rb, line 38
def available_formats
  AdFormat.constants.map { |format| format.to_s.underscore.to_sym }
end
get_dimension(format) click to toggle source
# File lib/ad_sense/ad_format.rb, line 22
def get_dimension(format)
  format_value = get_format_value(format)
  format_value.split('x').map(&:to_i)
rescue NameError
  []
end

Protected Class Methods

get_format_value(format) click to toggle source
# File lib/ad_sense/ad_format.rb, line 43
def get_format_value(format)
  if format.is_a?(String) && format.include?('x')
    format
  else
    AdFormat.const_get format.to_s.camelize
  end
rescue
  ''
end