Class: SlackPoster

Inherits:
Object
  • Object
show all
Defined in:
lib/slack_twitter_egosa/slack_poster.rb

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ SlackPoster

Returns a new instance of SlackPoster.

[View source]

6
7
8
9
10
# File 'lib/slack_twitter_egosa/slack_poster.rb', line 6

def initialize(url)
  @poster = Slack::Poster.new(url)
  @locker = Mutex::new
  @pushed_ids = []
end

Instance Method Details

#post_status(status) ⇒ Object

[View source]

12
13
14
15
16
17
18
19
20
21
# 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