Class: Walle::Robot

Inherits:
Object
  • Object
show all
Defined in:
lib/walle/robot.rb,
lib/walle/robot/router.rb,
lib/walle/robot/definitions.rb,
lib/walle/robot/router/route.rb,
lib/walle/robot/router/builder.rb

Defined Under Namespace

Classes: Definitions, Environment, Router

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, options = {}) ⇒ Robot

Returns a new instance of Robot.



33
34
35
36
37
# File 'lib/walle/robot.rb', line 33

def initialize(client, options = {})
  @client  = client
  @async   = !!options.delete(:async)
  @options = options
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



31
32
33
# File 'lib/walle/robot.rb', line 31

def client
  @client
end

Class Method Details

.inherited(subclass) ⇒ Object



18
19
20
21
# File 'lib/walle/robot.rb', line 18

def inherited(subclass)
  subclass._definitions.push(Definitions.new)
  super
end

.run(options = {}, &block) ⇒ Object



23
24
25
26
27
28
# File 'lib/walle/robot.rb', line 23

def run(options = {}, &block)
  client   = Slack::RealTime::Client.new(options)
  instance = new(client, options)
  instance.run(&block)
  instance
end

Instance Method Details

#async?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/walle/robot.rb', line 52

def async?
  @async
end

#run(&block) ⇒ Object



39
40
41
42
# File 'lib/walle/robot.rb', line 39

def run(&block)
  _definitions.apply_to(client)
  async? ? client.start_async(&block) : client.start!(&block)
end

#started?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/walle/robot.rb', line 48

def started?
  client.started?
end

#stopObject



44
45
46
# File 'lib/walle/robot.rb', line 44

def stop
  client.stop!
end