class SlackPoster

Public Class Methods

new(url) click to toggle source
# File lib/slack_twitter_egosa/slack_poster.rb, line 6
def initialize(url)
  @poster = Slack::Poster.new(url)
  @locker = Mutex::new
  @pushed_ids = []
end

Public Instance Methods

post_status(status) click to toggle source
# File lib/slack_twitter_egosa/slack_poster.rb, line 12
def post_status(status)
  @locker.synchronize do
    unless pushed?(status.id)
      @poster.icon_url = status.user.profile_image_url
      @poster.username = "#{status.user.name}(@#{status.user.screen_name})"
      @poster.send_message("#{status.attrs[:full_text]}\n#{status.url}")
      push(status.id)
    end
  end
end

Private Instance Methods

push(id) click to toggle source
# File lib/slack_twitter_egosa/slack_poster.rb, line 29
def push(id)
  @pushed_ids.push(id)
  @pushed_ids.shift if @pushed_ids.size > 50
end
pushed?(id) click to toggle source
# File lib/slack_twitter_egosa/slack_poster.rb, line 25
def pushed?(id)
  @pushed_ids.include?(id)
end