Class: SimpleSlack::Poster

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_slack/poster.rb

Instance Method Summary collapse

Constructor Details

#initialize(slack, simple_slack) ⇒ Poster

Returns a new instance of Poster.



2
3
4
5
# File 'lib/simple_slack/poster.rb', line 2

def initialize(slack, simple_slack)
  @slack = slack
  @simple_slack = simple_slack
end

Instance Method Details

#channel(to:, text:, name: "slacker", **options) ⇒ Object



14
15
16
17
# File 'lib/simple_slack/poster.rb', line 14

def channel(to: , text: , name: "slacker", **options)
  id = convert_channel_to_id(to.to_s)
  send_chat({ username: name, channel: id, text: text }.merge(options))
end

#channels(to:, text:, name: "slacker", **options) ⇒ Object



7
8
9
10
11
12
# File 'lib/simple_slack/poster.rb', line 7

def channels(to: , text: , name: "slacker", **options)
  to.all? do |t|
    id = convert_channel_to_id(t.to_s)
    send_chat({ username: name, channel: id, text: text }.merge(options))
  end
end

#chat(channel: nil, user: nil, text:, name: "slacker", **options) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/simple_slack/poster.rb', line 23

def chat(channel: nil, user: nil, text: , name: "slacker", **options)
  if channel
    self.channel({ to: channel, text: text, name: name }.merge(options))
  elsif user
    "yet"
  end
end

#im(to:, text:, name: "slacker", **options) ⇒ Object



38
39
40
41
# File 'lib/simple_slack/poster.rb', line 38

def im(to: , text: , name: "slacker", **options)
  id = convert_im_to_id(to.to_s)
  send_chat({ username: name, channel: id, text: text }.merge(options))
end

#ims(to:, text:, name: "slacker", **options) ⇒ Object



31
32
33
34
35
36
# File 'lib/simple_slack/poster.rb', line 31

def ims(to: , text: , name: "slacker", **options)
  to.all? do |t|
    id = convert_im_to_id(t.to_s)
    send_chat({ username: name, channel: id, text: text }.merge(options))
  end
end

#user(to:, text:, name: "slacker") ⇒ Object



19
20
21
# File 'lib/simple_slack/poster.rb', line 19

def user(to: , text: , name: "slacker")
  "yet"
end