Class: UnichronUtils::Quicktime

Inherits:
Object
  • Object
show all
Defined in:
lib/unichron.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time: Time.now, speed: 4) ⇒ Quicktime

Returns a new instance of Quicktime.



109
110
111
112
113
# File 'lib/unichron.rb', line 109

def initialize(time: Time.now, speed: 4)

  @time, @speed = Unichron.new(time).to_time, speed

end

Instance Attribute Details

#timeObject (readonly)

Returns the value of attribute time.



107
108
109
# File 'lib/unichron.rb', line 107

def time
  @time
end

Instance Method Details

#pauseObject



130
131
132
# File 'lib/unichron.rb', line 130

def pause()
  @state = :pause
end

#playObject



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

#startObject



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