Class: MotionPaddle
- Inherits:
-
Object
- Object
- MotionPaddle
- Defined in:
- lib/motion-paddle/paddle_setup.rb
Class Method Summary collapse
-
.activated(note) ⇒ Object
internal.
- .activated? ⇒ Boolean
- .activated_email ⇒ Object
- .activated_licence_code ⇒ Object (also: activated_license_code)
- .api_key ⇒ Object
-
.call_listeners(name, *args) ⇒ Object
internal.
- .can_force_exit=(can_force_exit) ⇒ Object
- .can_force_exit? ⇒ Boolean
-
.continue(note) ⇒ Object
internal.
- .currency ⇒ Object
- .current_price ⇒ Object
- .deactivate_licence ⇒ Object (also: deactivate_license)
- .dev_name ⇒ Object
- .enabled? ⇒ Boolean
- .image ⇒ Object
-
.licenceDeactivated(deactivated, message: deactivateMessage) ⇒ Object
internal.
- .listen(*names, &block) ⇒ Object
- .paddle_instance ⇒ Object
-
.paddleDidFailWithError(error) ⇒ Object
internal.
-
.plist ⇒ Object
internal.
- .product_id ⇒ Object
- .product_image ⇒ Object
- .product_name ⇒ Object
- .psk_instance ⇒ Object
- .psk_purchase_product(product_id, &block) ⇒ Object
- .psk_receipt_for_product_id(product_id) ⇒ Object
- .psk_show(product_ids = nil, &block) ⇒ Object
- .psk_show_product(product_id, &block) ⇒ Object
- .psk_valid_receipts ⇒ Object
-
.PSKDidCancel ⇒ Object
internal.
-
.PSKDidFailWithError(error) ⇒ Object
internal.
-
.PSKProductPurchased(transactionReceipt) ⇒ Object
internal.
- .setup(window = nil, &block) ⇒ Object
- .show_licencing ⇒ Object (also: show_licensing)
- .time_trial=(time_trial) ⇒ Object
- .time_trial? ⇒ Boolean
- .trial_days_left ⇒ Object
- .trial_duration ⇒ Object
- .trial_text ⇒ Object
- .vendor_id ⇒ Object
- .will_show_licensing_window=(will_show_licensing_window) ⇒ Object
- .will_show_licensing_window? ⇒ Boolean
Class Method Details
.activated(note) ⇒ Object
internal
195 196 197 |
# File 'lib/motion-paddle/paddle_setup.rb', line 195 def activated(note) call_listeners :activated, note end |
.activated? ⇒ Boolean
156 157 158 |
# File 'lib/motion-paddle/paddle_setup.rb', line 156 def activated? enabled? && paddle_instance.productActivated end |
.activated_email ⇒ Object
172 173 174 |
# File 'lib/motion-paddle/paddle_setup.rb', line 172 def activated_email enabled? && paddle_instance.activatedEmail end |
.activated_licence_code ⇒ Object Also known as: activated_license_code
166 167 168 |
# File 'lib/motion-paddle/paddle_setup.rb', line 166 def activated_licence_code enabled? && paddle_instance.activatedLicenceCode end |
.api_key ⇒ Object
23 24 25 |
# File 'lib/motion-paddle/paddle_setup.rb', line 23 def api_key self.plist['api_key'] end |
.call_listeners(name, *args) ⇒ Object
internal
189 190 191 192 |
# File 'lib/motion-paddle/paddle_setup.rb', line 189 def call_listeners(name, *args) @listeners ||= {} @listeners[name.to_sym].each { |block| block.call(name.to_sym, *args) } if @listeners.has_key?(name.to_sym) end |
.can_force_exit=(can_force_exit) ⇒ Object
73 74 75 |
# File 'lib/motion-paddle/paddle_setup.rb', line 73 def can_force_exit=(can_force_exit) enabled? && paddle_instance.setCanForceExit(can_force_exit) end |
.can_force_exit? ⇒ Boolean
69 70 71 |
# File 'lib/motion-paddle/paddle_setup.rb', line 69 def can_force_exit? enabled? && paddle_instance.canForceExit end |
.continue(note) ⇒ Object
internal
200 201 202 |
# File 'lib/motion-paddle/paddle_setup.rb', line 200 def continue(note) call_listeners :continue, note end |
.currency ⇒ Object
35 36 37 |
# File 'lib/motion-paddle/paddle_setup.rb', line 35 def currency self.plist['currency'] end |
.current_price ⇒ Object
27 28 29 |
# File 'lib/motion-paddle/paddle_setup.rb', line 27 def current_price self.plist['current_price'] end |
.deactivate_licence ⇒ Object Also known as: deactivate_license
176 177 178 |
# File 'lib/motion-paddle/paddle_setup.rb', line 176 def deactivate_licence enabled? && paddle_instance.deactivateLicence end |
.dev_name ⇒ Object
31 32 33 |
# File 'lib/motion-paddle/paddle_setup.rb', line 31 def dev_name self.plist['dev_name'] end |
.enabled? ⇒ Boolean
3 4 5 |
# File 'lib/motion-paddle/paddle_setup.rb', line 3 def enabled? (NSClassFromString('Paddle')!=nil) end |
.image ⇒ Object
39 40 41 |
# File 'lib/motion-paddle/paddle_setup.rb', line 39 def image self.plist['image'] end |
.licenceDeactivated(deactivated, message: deactivateMessage) ⇒ Object
internal
205 206 207 |
# File 'lib/motion-paddle/paddle_setup.rb', line 205 def licenceDeactivated(deactivated, message: deactivateMessage) call_listeners :deactivated, deactivated, deactivateMessage end |
.listen(*names, &block) ⇒ Object
115 116 117 118 119 120 121 122 |
# File 'lib/motion-paddle/paddle_setup.rb', line 115 def listen(*names, &block) return if block.nil? @listeners ||= {} names.each { |name| @listeners[name.to_sym] ||= [] @listeners[name.to_sym] << block } end |
.paddle_instance ⇒ Object
7 8 9 |
# File 'lib/motion-paddle/paddle_setup.rb', line 7 def paddle_instance enabled? && Paddle.sharedInstance end |
.paddleDidFailWithError(error) ⇒ Object
internal
210 211 212 |
# File 'lib/motion-paddle/paddle_setup.rb', line 210 def paddleDidFailWithError(error) call_listeners :error, error end |
.plist ⇒ Object
internal
183 184 185 186 |
# File 'lib/motion-paddle/paddle_setup.rb', line 183 def plist (@plist = NSBundle.mainBundle.objectForInfoDictionaryKey("MotionPaddle_#{NSBundle.mainBundle.infoDictionary['CFBundleShortVersionString']}")) && (@plist = @plist.first) unless @plist @plist end |
.product_id ⇒ Object
15 16 17 |
# File 'lib/motion-paddle/paddle_setup.rb', line 15 def product_id self.plist['product_id'] end |
.product_image ⇒ Object
55 56 57 |
# File 'lib/motion-paddle/paddle_setup.rb', line 55 def product_image self.plist['product_image'] end |
.product_name ⇒ Object
43 44 45 |
# File 'lib/motion-paddle/paddle_setup.rb', line 43 def product_name self.plist['product_name'] end |
.psk_instance ⇒ Object
11 12 13 |
# File 'lib/motion-paddle/paddle_setup.rb', line 11 def psk_instance enabled? && PaddleStoreKit.sharedInstance end |
.psk_purchase_product(product_id, &block) ⇒ Object
144 145 146 147 148 149 150 |
# File 'lib/motion-paddle/paddle_setup.rb', line 144 def psk_purchase_product(product_id, &block) return unless enabled? psk = psk_instance psk.setDelegate(self) psk.purchaseProduct(product_id) listen(:psk_purchase, &block) end |
.psk_receipt_for_product_id(product_id) ⇒ Object
89 90 91 |
# File 'lib/motion-paddle/paddle_setup.rb', line 89 def psk_receipt_for_product_id(product_id) enabled? && psk_instance.receiptForProductId(product_id) end |
.psk_show(product_ids = nil, &block) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/motion-paddle/paddle_setup.rb', line 124 def psk_show(product_ids = nil, &block) return unless enabled? psk = psk_instance psk.setDelegate(self) if product_ids && !product_ids.empty? psk.showStoreViewForProductIds(product_ids) else psk.showStoreView end listen(:psk_purchase, &block) end |
.psk_show_product(product_id, &block) ⇒ Object
136 137 138 139 140 141 142 |
# File 'lib/motion-paddle/paddle_setup.rb', line 136 def psk_show_product(product_id, &block) return unless enabled? psk = psk_instance psk.setDelegate(self) psk.showProduct(product_id) listen(:psk_purchase, &block) end |
.psk_valid_receipts ⇒ Object
85 86 87 |
# File 'lib/motion-paddle/paddle_setup.rb', line 85 def psk_valid_receipts enabled? && psk_instance.validReceipts end |
.PSKDidCancel ⇒ Object
internal
225 226 227 |
# File 'lib/motion-paddle/paddle_setup.rb', line 225 def PSKDidCancel call_listeners :psk_cancel end |
.PSKDidFailWithError(error) ⇒ Object
internal
220 221 222 |
# File 'lib/motion-paddle/paddle_setup.rb', line 220 def PSKDidFailWithError(error) call_listeners :psk_error, error end |
.PSKProductPurchased(transactionReceipt) ⇒ Object
internal
215 216 217 |
# File 'lib/motion-paddle/paddle_setup.rb', line 215 def PSKProductPurchased(transactionReceipt) call_listeners :psk_purchase, transactionReceipt end |
.setup(window = nil, &block) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/motion-paddle/paddle_setup.rb', line 93 def setup(window = nil, &block) return unless enabled? return unless self.plist paddle = paddle_instance paddle.setProductId(product_id) paddle.setVendorId(vendor_id) paddle.setApiKey(api_key) paddle.startLicensing({ KPADCurrentPrice => current_price, KPADDevName => dev_name, KPADCurrency => currency, KPADImage => image, KPADProductName => product_name, KPADTrialDuration => trial_duration, KPADTrialText => trial_text, KPADProductImage => product_image }, timeTrial: time_trial?, withWindow: window) NSNotificationCenter.defaultCenter.addObserver(self, selector: 'activated:', name: KPADActivated, object: nil) NSNotificationCenter.defaultCenter.addObserver(self, selector: 'continue:', name: KPADContinue, object: nil) paddle.setDelegate(self) # block.call unless block.nil? listen(:activated, :continue, &block) end |
.show_licencing ⇒ Object Also known as: show_licensing
160 161 162 |
# File 'lib/motion-paddle/paddle_setup.rb', line 160 def show_licencing enabled? && paddle_instance.showLicencing end |
.time_trial=(time_trial) ⇒ Object
64 65 66 67 |
# File 'lib/motion-paddle/paddle_setup.rb', line 64 def time_trial=(time_trial) paddle_instance.setIsTimeTrial(time_trial) if enabled? @time_trial = time_trial end |
.time_trial? ⇒ Boolean
59 60 61 62 |
# File 'lib/motion-paddle/paddle_setup.rb', line 59 def time_trial? @time_trial = self.plist['time_trial'] && self.plist['time_trial'] != 0 && self.plist['time_trial'] != '0' if @time_trial.nil? @time_trial end |
.trial_days_left ⇒ Object
152 153 154 |
# File 'lib/motion-paddle/paddle_setup.rb', line 152 def trial_days_left enabled? && paddle_instance.daysRemainingOnTrial end |
.trial_duration ⇒ Object
47 48 49 |
# File 'lib/motion-paddle/paddle_setup.rb', line 47 def trial_duration self.plist['trial_duration'] end |
.trial_text ⇒ Object
51 52 53 |
# File 'lib/motion-paddle/paddle_setup.rb', line 51 def trial_text self.plist['trial_text'] end |
.vendor_id ⇒ Object
19 20 21 |
# File 'lib/motion-paddle/paddle_setup.rb', line 19 def vendor_id self.plist['vendor_id'] end |
.will_show_licensing_window=(will_show_licensing_window) ⇒ Object
81 82 83 |
# File 'lib/motion-paddle/paddle_setup.rb', line 81 def will_show_licensing_window=(will_show_licensing_window) enabled? && paddle_instance.setWillShowLicensingWindow(will_show_licensing_window) end |
.will_show_licensing_window? ⇒ Boolean
77 78 79 |
# File 'lib/motion-paddle/paddle_setup.rb', line 77 def will_show_licensing_window? enabled? && paddle_instance.willShowLicensingWindow end |