class SocketCake

Attributes

storage[RW]
task_list[RW]

Public Class Methods

new(cookie, task_list=[]) click to toggle source
# File lib/socketcake.rb, line 7
def initialize cookie, task_list=[]
  @cookie = cookie
  @task_list = task_list
  @storage = Hash.new
end

Public Instance Methods

roll() click to toggle source
# 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

Private Instance Methods

create_sockets(task_list) click to toggle source
# File lib/socketcake.rb, line 26
def create_sockets (task_list)

  task_list.each do |task|
    klass = Object.const_get(task.name)
    if klass.superclass == BaseSocket
      self.instance_variable_set(:"@#{task.name.downcase}", klass.new(task.task_list, task.url, task.openmessage, @cookie, task.verbose))
    end
  end
end