class Motion::Admob::Interstitial::InterstitialAd
Public Class Methods
new(options={})
click to toggle source
# File lib/motion/admob/interstitial/interstitial_ad.rb, line 3 def initialize(options={}) @callbacks = {} @ad_unit_id = options[:ad_unit_id] @once_a_nth = options[:once_a_nth] || 1 @auto_reload = !!options[:auto_reload] raise "ad_unit_id is missing" unless @ad_unit_id request end
Public Instance Methods
callback(type, &block)
click to toggle source
# File lib/motion/admob/interstitial/interstitial_ad.rb, line 18 def callback(type, &block) @callbacks[type] = block end
interstitial(interstitial, didFailToReceiveAdWithError:error)
click to toggle source
# File lib/motion/admob/interstitial/interstitial_ad.rb, line 26 def interstitial(interstitial, didFailToReceiveAdWithError:error) @callbacks[:error].call(interstitial, error) if @callbacks[:error] end
interstitialDidDismissScreen(interstitial)
click to toggle source
# File lib/motion/admob/interstitial/interstitial_ad.rb, line 38 def interstitialDidDismissScreen(interstitial) request if @auto_reload @callbacks[:did_dismiss_screen].call(interstitial) if @callbacks[:did_dismiss_screen] end
interstitialDidReceiveAd(interstitial)
click to toggle source
# File lib/motion/admob/interstitial/interstitial_ad.rb, line 22 def interstitialDidReceiveAd(interstitial) @callbacks[:did_receive_ad].call(interstitial) if @callbacks[:did_receive_ad] end
interstitialWillDismissScreen(interstitial)
click to toggle source
# File lib/motion/admob/interstitial/interstitial_ad.rb, line 34 def interstitialWillDismissScreen(interstitial) @callbacks[:will_dismiss_screen].call(interstitial) if @callbacks[:will_dismiss_screen] end
interstitialWillLeaveApplication(interstitial)
click to toggle source
# File lib/motion/admob/interstitial/interstitial_ad.rb, line 43 def interstitialWillLeaveApplication(interstitial) @callbacks[:will_leave_application].call(interstitial) if @callbacks[:will_leave_application] end
interstitialWillPresentScreen(interstitial)
click to toggle source
# File lib/motion/admob/interstitial/interstitial_ad.rb, line 30 def interstitialWillPresentScreen(interstitial) @callbacks[:will_present_screen].call(interstitial) if @callbacks[:will_present_screen] end
present(controller)
click to toggle source
# File lib/motion/admob/interstitial/interstitial_ad.rb, line 12 def present(controller) if rand(@once_a_nth) == 0 @interstitial.presentFromRootViewController controller end end
Private Instance Methods
request()
click to toggle source
# File lib/motion/admob/interstitial/interstitial_ad.rb, line 49 def request @interstitial = GADInterstitial.alloc.init @interstitial.delegate = self @interstitial.adUnitID = @ad_unit_id @interstitial.loadRequest GADRequest.request end