Class: ConsadoleAggregator::Live::Runner
- Inherits:
-
Object
- Object
- ConsadoleAggregator::Live::Runner
- Defined in:
- lib/consadole_aggregator/live.rb
Instance Attribute Summary collapse
-
#daemonize ⇒ Object
writeonly
Sets the attribute daemonize.
-
#interval ⇒ Object
writeonly
Sets the attribute interval.
-
#length_of_a_game ⇒ Object
writeonly
Sets the attribute length_of_a_game.
Instance Method Summary collapse
-
#initialize(starting_time) ⇒ Runner
constructor
A new instance of Runner.
- #run(&block) ⇒ Object
Constructor Details
#initialize(starting_time) ⇒ Runner
Returns a new instance of Runner.
13 14 15 16 17 18 |
# File 'lib/consadole_aggregator/live.rb', line 13 def initialize starting_time @starting_time = starting_time @length_of_a_game = 120 * 60 @interval = 60 @daemonize = true end |
Instance Attribute Details
#daemonize=(value) ⇒ Object (writeonly)
Sets the attribute daemonize
11 12 13 |
# File 'lib/consadole_aggregator/live.rb', line 11 def daemonize=(value) @daemonize = value end |
#interval=(value) ⇒ Object (writeonly)
Sets the attribute interval
11 12 13 |
# File 'lib/consadole_aggregator/live.rb', line 11 def interval=(value) @interval = value end |
#length_of_a_game=(value) ⇒ Object (writeonly)
Sets the attribute length_of_a_game
11 12 13 |
# File 'lib/consadole_aggregator/live.rb', line 11 def length_of_a_game=(value) @length_of_a_game = value end |
Instance Method Details
#run(&block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/consadole_aggregator/live.rb', line 20 def run &block Process.daemon if @daemonize starting = @starting_time - Time.now ending = starting + @length_of_a_game live = Live.new EM.run do EM.add_timer(starting) do EM.next_tick do EM.add_periodic_timer(@interval) do live.update &block end end end EM.add_timer(ending) do EM.stop end end end |