Last active
December 22, 2015 16:49
-
-
Save luisgerhorst/6502192 to your computer and use it in GitHub Desktop.
Creating my first Mac app with MacRuby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# AppDelegate.rb | |
# Alarm | |
# | |
# Created by Luis Gerhorst on 09.09.13. | |
# | |
class AppDelegate | |
attr_accessor :window, :datePicker, :createAlarmButton, :deleteAlarmButton | |
def applicationDidFinishLaunching(a_notification) | |
datePicker.setDateValue(NSDate.date) | |
end | |
def createAlarm(sender) | |
puts "creating..." | |
@alarm = Alarm.new | |
@alarm.timer(datePicker.dateValue) | |
end | |
def deleteAlarm(sender) | |
puts "deleting..." | |
@alarm.delete | |
@alarm = nil | |
end | |
end | |
class Alarm | |
def timer(date) | |
@timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: "fire:", userInfo: nil, repeats: true) | |
@timer.setFireDate(date) | |
puts "created" | |
end | |
def fire(userInfo) | |
NSSound.soundNamed('Basso').play | |
puts "fired" | |
end | |
def delete | |
@timer.invalidate | |
@timer = nil | |
puts "deleted" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment