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.



54
55
56
57
58
# File 'lib/unichron.rb', line 54

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.



52
53
54
# File 'lib/unichron.rb', line 52

def time
  @time
end

Instance Method Details

#pauseObject



75
76
77
# File 'lib/unichron.rb', line 75

def pause()
  @state = :pause
end

#playObject



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

#startObject



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