Class: UnichronUtils::Quicktime
- Inherits:
-
Object
- Object
- UnichronUtils::Quicktime
- Defined in:
- lib/unichron.rb
Instance Attribute Summary collapse
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
-
#initialize(time: Time.now, speed: 4) ⇒ Quicktime
constructor
A new instance of Quicktime.
- #pause ⇒ Object
- #play ⇒ Object
- #set_time(s) ⇒ Object
- #start ⇒ Object
Constructor Details
Instance Attribute Details
#time ⇒ Object (readonly)
Returns the value of attribute time.
100 101 102 |
# File 'lib/unichron.rb', line 100 def time @time end |
Instance Method Details
#pause ⇒ Object
123 124 125 |
# File 'lib/unichron.rb', line 123 def pause() @state = :pause end |
#play ⇒ Object
127 128 129 |
# File 'lib/unichron.rb', line 127 def play() @state = :play end |
#set_time(s) ⇒ Object
131 132 133 |
# File 'lib/unichron.rb', line 131 def set_time(s) @time = Chronic.parse(s) end |
#start ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/unichron.rb', line 108 def start() @state = :play Thread.new do loop do (sleep 0.5; next) if @state == :pause @time += 1 sleep 1.0 / @speed end end end |