Class: PeertransferChat::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/peertransfer_chat/client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



15
16
17
18
19
20
# File 'lib/peertransfer_chat/client.rb', line 15

def initialize
  if block_given?
    @config = Config.new
    yield(@config)
  end
end

Instance Attribute Details

#config=(value) ⇒ Object

Sets the attribute config

Parameters:

  • value

    the value to set the attribute config to.



5
6
7
# File 'lib/peertransfer_chat/client.rb', line 5

def config=(value)
  @config = value
end

Class Method Details

.speak(something) ⇒ Object



11
12
13
# File 'lib/peertransfer_chat/client.rb', line 11

def self.speak(something)
  new.speak(something)
end

.upload(filename) ⇒ Object



7
8
9
# File 'lib/peertransfer_chat/client.rb', line 7

def self.upload(filename)
  new.upload(filename)
end

Instance Method Details

#speak(message) ⇒ Object



33
34
35
# File 'lib/peertransfer_chat/client.rb', line 33

def speak(message)
  client.chat_postMessage(channel: channel, text: message, as_user: true, username: username)
end

#upload(filename, opts = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/peertransfer_chat/client.rb', line 22

def upload(filename, opts = {})
  client.files_upload(
    channels: channel,
    as_user: true,
    file: Faraday::UploadIO.new(filename, 'image/png'),
    title: 'output.txt',
    filename: filename,
    initial_comment: 'Attachment'
  )
end