diff --git a/app/app_delegate.rb b/app/app_delegate.rb index 754a40b..7cc5689 100644 --- a/app/app_delegate.rb +++ b/app/app_delegate.rb @@ -16,7 +16,8 @@ def applicationDidFinishLaunching(notification) @status_menu.addItem createMenuItem('Donations Appreciated', 'donations') @status_menu.addItem createMenuItem('Quit', 'terminate:') - self.checkPrice + NSTimer.scheduledTimerWithTimeInterval(INTERVAL, target: self, selector: 'checkValue', userInfo: nil, repeats: true) + self.checkValue end def createMenuItem(name, action) @@ -31,11 +32,9 @@ def donations alert.runModal end - def checkPrice + def checkValue Dogecoin.toBtc do |price| @status_item.setTitle("Ð #{price}") end - - NSTimer.scheduledTimerWithTimeInterval(INTERVAL, target: self, selector: 'checkPrice', userInfo: nil, repeats: true) end end diff --git a/app/dogecoin.rb b/app/dogecoin.rb index e71aed3..2eea42a 100644 --- a/app/dogecoin.rb +++ b/app/dogecoin.rb @@ -4,7 +4,9 @@ def toBtc(&block) AFMotion::JSON.get('http://pubapi.cryptsy.com/api.php?method=singlemarketdata&marketid=132') do |result| if result.success? json = result.object - block.call(json[:return][:markets][:DOGE][:lasttradeprice]) + btcValue = json[:return][:markets][:DOGE][:lasttradeprice] + + block.call(btcValue) end end end