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.
107 108 109 |
# File 'lib/unichron.rb', line 107 def time @time end |
Instance Method Details
#pause ⇒ Object
130 131 132 |
# File 'lib/unichron.rb', line 130 def pause() @state = :pause end |
#play ⇒ Object
134 135 136 |
# File 'lib/unichron.rb', line 134 def play() @state = :play end |
#set_time(s) ⇒ Object
138 139 140 |
# File 'lib/unichron.rb', line 138 def set_time(s) @time = Chronic.parse(s) end |
#start ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/unichron.rb', line 115 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 |