Sha256: e05f103002c32c37eb914809b23b96fd6a2699cbca6f2387619faf80d27791b5

Contents?: true

Size: 1015 Bytes

Versions: 5

Compression:

Stored size: 1015 Bytes

Contents

# -*- coding: utf-8 -*-
require 'twitter'

module ConsadoleAggregator
  module Live
    module Builder
      class Twit
        def initialize
          Process.daemon(true, false)
          @client = Twitter::Client.from_config('config/account.yaml')
          @posted = []
        end

        def post
          new_line.each do |line|
            @client.status(:post, "#{line.time} #{line.post} #consadole")
            @posted << line
          end
        end

        def reserve start_time
          start = Time.parse start_time
          ConsadoleAggregator::log.info("#{start.to_time}くらいにはじめる予定")
          sleep start - Time.now

          live
        end

        def live
          # サッカーはハーフタイム含めて120分位あれば終わる
          120.times do
            post
            sleep 60
          end
        end

        private
        def new_line
          ConsadoleAggregator::Live::Parser.parse - @posted
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
consadole_aggregator-0.0.4 lib/consadole_aggregator/live/builder.rb
consadole_aggregator-0.0.3 lib/consadole_aggregator/live/builder.rb
consadole_aggregator-0.0.2 lib/consadole_aggregator/live/builder.rb
consadole_aggregator-0.0.1 lib/consadole_aggregator/live/builder.rb
consadole_aggregator-0.0.0 lib/consadole_aggregator/live/builder.rb