Class: ConsadoleAggregator::Live

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

Defined Under Namespace

Classes: Runner

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLive

Returns a new instance of Live.



53
54
55
# File 'lib/consadole_aggregator/live.rb', line 53

def initialize
  @posted = []
end

Instance Attribute Details

#postedObject (readonly)

Returns the value of attribute posted.



51
52
53
# File 'lib/consadole_aggregator/live.rb', line 51

def posted
  @posted
end

Class Method Details

.run(starting_time, opt = {}) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/consadole_aggregator/live.rb', line 43

def self.run starting_time, opt = {}
  runner = Runner.new starting_time
  runner.length_of_a_game = opt[:length_of_a_game] if opt[:length_of_a_game]
  runner.interval = opt[:interval] if opt[:interval]
  runner.daemonize = opt[:daemonize] unless opt[:daemonize].nil?
  runner.run &opt[:writer]
end

Instance Method Details

#updateObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/consadole_aggregator/live.rb', line 57

def update
  self.class
    .fetch
    .reject(&@posted.method(:include?))
    .each_with_object(@posted) { |post, posted|
    begin
      yield({ title: post }) if block_given?
      posted << post
      ConsadoleAggregator.logger.info post
    rescue
      ConsadoleAggregator.logger.error $!
    end
  }
end