Class: Glimmer::Timer
- Inherits:
-
Object
- Object
- Glimmer::Timer
- Includes:
- UI::CustomShell
- Defined in:
- lib/views/glimmer/timer.rb
Constant Summary collapse
- APP_ROOT =
File.('../../../..', __FILE__)
- VERSION =
File.read(File.join(APP_ROOT, 'VERSION'))
- LICENSE =
File.read(File.join(APP_ROOT, 'LICENSE.txt'))
- FILE_SOUND_ALARM =
File.join(APP_ROOT, 'sounds', 'alarm1.wav')
Instance Attribute Summary collapse
-
#countdown ⇒ Object
Add options like the following to configure CustomShell by outside consumers.
-
#min ⇒ Object
Add options like the following to configure CustomShell by outside consumers.
-
#sec ⇒ Object
Add options like the following to configure CustomShell by outside consumers.
Instance Method Summary collapse
- #display_about_dialog ⇒ Object
- #play_countdown_done_sound ⇒ Object
- #start_countdown ⇒ Object
- #stop_countdown ⇒ Object
Instance Attribute Details
#countdown ⇒ Object
Add options like the following to configure CustomShell by outside consumers
options :title, :background_color option :width, default: 320 option :height, default: 240
18 19 20 |
# File 'lib/views/glimmer/timer.rb', line 18 def countdown @countdown end |
#min ⇒ Object
Add options like the following to configure CustomShell by outside consumers
options :title, :background_color option :width, default: 320 option :height, default: 240
18 19 20 |
# File 'lib/views/glimmer/timer.rb', line 18 def min @min end |
#sec ⇒ Object
Add options like the following to configure CustomShell by outside consumers
options :title, :background_color option :width, default: 320 option :height, default: 240
18 19 20 |
# File 'lib/views/glimmer/timer.rb', line 18 def sec @sec end |
Instance Method Details
#display_about_dialog ⇒ Object
148 149 150 151 152 153 |
# File 'lib/views/glimmer/timer.rb', line 148 def display_about_dialog (body_root) { text 'About' "Glimmer - Timer #{VERSION}\n\n#{LICENSE}" }.open end |
#play_countdown_done_sound ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/views/glimmer/timer.rb', line 165 def play_countdown_done_sound begin if FILE_SOUND_ALARM.start_with?('uri:classloader') jar_file_path = FILE_SOUND_ALARM file_path = jar_file_path.sub(/^uri\:classloader\:/, '').sub('//', '/') # the latter sub is needed for Mac object = java.lang.Object.new file_input_stream = object.java_class.resource_as_stream(file_path) file_or_stream = java.io.BufferedInputStream.new(file_input_stream) else file_or_stream = java.io.File.new(FILE_SOUND_ALARM) end audio_stream = AudioSystem.get_audio_input_stream(file_or_stream) clip = AudioSystem.clip clip.open(audio_stream) clip.start rescue => e pd e puts e. end end |
#start_countdown ⇒ Object
155 156 157 158 |
# File 'lib/views/glimmer/timer.rb', line 155 def start_countdown self.countdown = true @stop_button..set_focus end |
#stop_countdown ⇒ Object
160 161 162 163 |
# File 'lib/views/glimmer/timer.rb', line 160 def stop_countdown self.countdown = false @min_spinner..set_focus end |