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.
52 53 54 |
# File 'lib/unichron.rb', line 52 def time @time end |
Instance Method Details
#pause ⇒ Object
75 76 77 |
# File 'lib/unichron.rb', line 75 def pause() @state = :pause end |
#play ⇒ Object
79 80 81 |
# File 'lib/unichron.rb', line 79 def play() @state = :play end |
#set_time(s) ⇒ Object
83 84 85 |
# File 'lib/unichron.rb', line 83 def set_time(s) @time = Chronic.parse(s) end |
#start ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/unichron.rb', line 60 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 |