Class: Motion::Admob::Interstitial::InterstitialAd
- Inherits:
-
Object
- Object
- Motion::Admob::Interstitial::InterstitialAd
- Defined in:
- lib/motion/admob/interstitial/interstitial_ad.rb
Instance Method Summary collapse
- #callback(type, &block) ⇒ Object
-
#initialize(options = {}) ⇒ InterstitialAd
constructor
A new instance of InterstitialAd.
- #interstitial(interstitial, didFailToReceiveAdWithError: error) ⇒ Object
- #interstitialDidDismissScreen(interstitial) ⇒ Object
- #interstitialDidReceiveAd(interstitial) ⇒ Object
- #interstitialWillDismissScreen(interstitial) ⇒ Object
- #interstitialWillLeaveApplication(interstitial) ⇒ Object
- #interstitialWillPresentScreen(interstitial) ⇒ Object
- #present(controller) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ InterstitialAd
Returns a new instance of InterstitialAd.
3 4 5 6 7 8 9 10 |
# File 'lib/motion/admob/interstitial/interstitial_ad.rb', line 3 def initialize(={}) @callbacks = {} @ad_unit_id = [:ad_unit_id] @once_a_nth = [:once_a_nth] || 1 @auto_reload = !![:auto_reload] raise "ad_unit_id is missing" unless @ad_unit_id request end |
Instance Method Details
#callback(type, &block) ⇒ Object
18 19 20 |
# File 'lib/motion/admob/interstitial/interstitial_ad.rb', line 18 def callback(type, &block) @callbacks[type] = block end |
#interstitial(interstitial, didFailToReceiveAdWithError: error) ⇒ Object
26 27 28 |
# 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) ⇒ Object
38 39 40 41 |
# 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) ⇒ Object
22 23 24 |
# 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) ⇒ Object
34 35 36 |
# 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) ⇒ Object
43 44 45 |
# 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) ⇒ Object
30 31 32 |
# 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) ⇒ Object
12 13 14 15 16 |
# File 'lib/motion/admob/interstitial/interstitial_ad.rb', line 12 def present(controller) if rand(@once_a_nth) == 0 @interstitial.presentFromRootViewController controller end end |