Class: SocketCake

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

Defined Under Namespace

Classes: BaseSocket, WsTask

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cookie, task_list = []) ⇒ SocketCake

Returns a new instance of SocketCake.



7
8
9
10
11
# File 'lib/socketcake.rb', line 7

def initialize cookie, task_list=[]
  @cookie = cookie
  @task_list = task_list
  @storage = Hash.new
end

Instance Attribute Details

#storageObject

Returns the value of attribute storage.



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

def storage
  @storage
end

#task_listObject

Returns the value of attribute task_list.



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

def task_list
  @task_list
end

Instance Method Details

#rollObject



13
14
15
16
17
18
19
20
21
# File 'lib/socketcake.rb', line 13

def roll
  EM.run do
    create_sockets @task_list
    task_list.each do |task|
      t = self.instance_variable_get(:"@#{task.name.downcase}")
      t.start { |data| @storage[t.class.to_s]=data; EM.stop if task == task_list.last }
    end
  end
end