Class: FuckBot::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



5
6
7
8
9
10
11
# File 'lib/fuck_bot/client.rb', line 5

def initialize(options = {})
  @token  = options.fetch(:token, ENV['FUCK_BOT_TOKEN'])
  @logger = options.fetch(:logger, Logger.new(STDOUT))
  @store  = FuckBot::Store.new(options[:store])

  rtm_start
end

Instance Attribute Details

#storeObject (readonly)

Returns the value of attribute store.



3
4
5
# File 'lib/fuck_bot/client.rb', line 3

def store
  @store
end

#tokenObject (readonly)

Returns the value of attribute token.



3
4
5
# File 'lib/fuck_bot/client.rb', line 3

def token
  @token
end

#urlObject (readonly)

Returns the value of attribute url.



3
4
5
# File 'lib/fuck_bot/client.rb', line 3

def url
  @url
end

#userObject (readonly)

Returns the value of attribute user.



3
4
5
# File 'lib/fuck_bot/client.rb', line 3

def user
  @user
end

#wsObject (readonly)

Returns the value of attribute ws.



3
4
5
# File 'lib/fuck_bot/client.rb', line 3

def ws
  @ws
end

Instance Method Details

#runObject



13
14
15
16
17
18
19
# File 'lib/fuck_bot/client.rb', line 13

def run
  @ws = Faye::WebSocket::Client.new(@url)

  @ws.on(:open, on_open)
  @ws.on(:message, on_message)
  @ws.on(:close, on_close)
end